Skip to content

Commit

Permalink
Give some love to the project
Browse files Browse the repository at this point in the history
- Update Scala version
- Update sbt and sbt plugins
- Remove deprecated sbt syntax usages
- Update Scalafix and improve its configuration
- Install Scala Steward to help us maintain this project
- Fix Scalafix issues in code
  • Loading branch information
guizmaii committed Jul 16, 2023
1 parent 40a86b2 commit 5880888
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 27 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/scala-steward.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Scala Steward

# This workflow will launch everyday at 00:00
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: {}

jobs:
scala-steward:
timeout-minutes: 30
runs-on: ubuntu-latest
name: Scala Steward
steps:
- name: Scala Steward
uses: scala-steward-org/[email protected]
25 changes: 24 additions & 1 deletion .scalafix.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
rules = [
OrganizeImports,
DisableSyntax
ExplicitResultTypes
LeakingImplicitClassVal
NoAutoTupling
NoValInForComprehension
ProcedureSyntax
RemoveUnused
OrganizeImports
]

RemoveUnused {
imports = false // See https://github.com/scalacenter/scalafix/blob/v0.11.0/docs/rules/OrganizeImports.md#configuration
}

Disable {
ifSynthetic = [
"scala/Option.option2Iterable"
"scala/Predef.any2stringadd"
]
}

DisableSyntax.noReturns = true
DisableSyntax.noXml = true
DisableSyntax.noFinalize = true
DisableSyntax.noValPatterns = true

ExplicitResultTypes.rewriteStructuralTypesToNamedSubclass = false

OrganizeImports.groupedImports = Explode
Expand Down
15 changes: 8 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
def scala212 = "2.12.12"
def scala212 = "2.12.18"

Global / onChangedBuildSource := ReloadOnSourceChanges

inThisBuild(
List(
organization := "org.scalameta",
Expand All @@ -15,16 +18,14 @@ inThisBuild(
)
),
scalaVersion := scala212,
scalafixDependencies +=
"com.github.liancheng" %% "organize-imports" % "0.5.0",
scalacOptions ++= List("-Ywarn-unused-import"),
scalafixCaching := true,
semanticdbEnabled := true
)
)

crossScalaVersions := Nil
skip.in(publish) := true
publish / skip := true

commands +=
Command.command("fixAll") { s =>
Expand All @@ -42,7 +43,7 @@ lazy val plugin = project
.settings(
moduleName := "sbt-native-image",
sbtPlugin := true,
sbtVersion.in(pluginCrossBuild) := "1.0.0",
pluginCrossBuild / sbtVersion := "1.0.0",
crossScalaVersions := List(scala212),
buildInfoPackage := "sbtnativeimage",
buildInfoKeys := Seq[BuildInfoKey](version),
Expand All @@ -55,8 +56,8 @@ lazy val plugin = project
lazy val example = project
.in(file("example"))
.settings(
skip.in(publish) := true,
mainClass.in(Compile) := Some("example.Hello"),
publish / skip := true,
Compile / mainClass := Some("example.Hello"),
test := {
val binary = nativeImage.value
val output = scala.sys.process.Process(List(binary.toString)).!!.trim
Expand Down
19 changes: 9 additions & 10 deletions plugin/src/main/scala/sbtnativeimage/NativeImagePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,7 @@ object NativeImagePlugin extends AutoPlugin {
//this happens if the dependency jar resides on a different drive then the manifest, i.e. C:\Coursier\Cache and D:\myapp\target
//copy dependency next to manifest as fallback
case _: IllegalArgumentException =>
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import java.nio.file.{Files, StandardCopyOption}
Files.copy(
dependencyPath,
manifestPath.resolve(path.getName),
Expand All @@ -546,15 +545,15 @@ object NativeImagePlugin extends AutoPlugin {

private def alertUser(streams: std.TaskStreams[_], message: String): Unit = {
streams.log.info(message)
if (isCI)
return
try {
if (Properties.isMac) {
Process(List("say", message)).!
if (!isCI) {
try {
if (Properties.isMac) {
Process(List("say", message)).!
}
// NOTE(olafur): feel free to add support for Linux/Windows.
} catch {
case NonFatal(_) =>
}
// NOTE(olafur): feel free to add support for Linux/Windows.
} catch {
case NonFatal(_) =>
}
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.4
sbt.version=1.9.2
16 changes: 8 additions & 8 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.4")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.27")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0")

libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value

unmanagedSourceDirectories.in(Compile) +=
baseDirectory.in(ThisBuild).value.getParentFile / "plugin" / "src" / "main" /
Compile / unmanagedSourceDirectories +=
(ThisBuild / baseDirectory).value.getParentFile / "plugin" / "src" / "main" /
"scala"
unmanagedResourceDirectories.in(Compile) +=
baseDirectory.in(ThisBuild).value.getParentFile / "plugin" / "src" / "main" /
Compile / unmanagedResourceDirectories +=
(ThisBuild / baseDirectory).value.getParentFile / "plugin" / "src" / "main" /
"resources"

0 comments on commit 5880888

Please sign in to comment.