Skip to content

Commit

Permalink
Update Scalafmt config
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii committed Jul 16, 2023
1 parent 9f3d5db commit 5f0a1fa
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version = "2.7.5"
version = "3.7.8"
runner.dialect = sbt1
assumeStandardLibraryStripMargin = true
docstrings.style = Asterisk
docstrings.wrap = "yes"
Expand Down
27 changes: 17 additions & 10 deletions plugin/src/main/scala/sbtnativeimage/NativeImagePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,14 @@ object NativeImagePlugin extends AutoPlugin {

override lazy val projectSettings: Seq[Def.Setting[_]] = List(
libraryDependencies += "org.scalameta" % "svm-subs" % "101.0.0",
NativeImage / target := (Compile / target).value / "native-image",
NativeImageTest / target := (Test / target).value / "native-image-test",
NativeImageInternal / target := (Compile / target).value / "native-image-internal",
NativeImageTestInternal / target := (Test / target).value / "native-image-test-internal",
NativeImage / target :=
(Compile / target).value / "native-image",
NativeImageTest / target :=
(Test / target).value / "native-image-test",
NativeImageInternal / target :=
(Compile / target).value / "native-image-internal",
NativeImageTestInternal / target :=
(Test / target).value / "native-image-test-internal",
nativeImageReady := {
val s = streams.value

Expand All @@ -162,9 +166,12 @@ object NativeImagePlugin extends AutoPlugin {
nativeImageJvmIndex := "cs",
nativeImageVersion := "20.2.0",
NativeImage / name := name.value,
NativeImageTest / name := (Test / name).value,
NativeImage / mainClass := (Compile / mainClass).value,
NativeImageTest / mainClass := (Test / mainClass).value,
NativeImageTest / name :=
(Test / name).value,
NativeImage / mainClass :=
(Compile / mainClass).value,
NativeImageTest / mainClass :=
(Test / mainClass).value,
nativeImageOptions := List.empty,
nativeImageTestOptions := nativeImageOptions.value,
nativeImageTestRunOptions := List.empty,
Expand Down Expand Up @@ -513,9 +520,9 @@ object NativeImagePlugin extends AutoPlugin {
try {
manifestPath.relativize(dependencyPath).toString
} catch {
//java.lang.IllegalArgumentException: 'other' has different root
//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
// java.lang.IllegalArgumentException: 'other' has different root
// 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, StandardCopyOption}
Files.copy(
Expand Down
31 changes: 18 additions & 13 deletions plugin/src/sbt-test/sbt-native-image/agent-test/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@ lazy val example = project
.settings(
scalaVersion := "2.12.12",
mainClass.in(Compile) := Some("example.Hello6"),
nativeImageTestOptions ++= Seq(
s"-H:ReflectionConfigurationFiles=${target.value / "native-image-configs" / "reflect-config.json"}",
"--initialize-at-build-time=scala.collection.immutable.VM",
),
nativeImageTestOptions ++=
Seq(
s"-H:ReflectionConfigurationFiles=${target.value / "native-image-configs" / "reflect-config.json"}",
"--initialize-at-build-time=scala.collection.immutable.VM"
),
mainClass.in(Test) := Some("org.scalatest.tools.Runner"),
nativeImageTestRunOptions ++= Seq("-o", "-R", classDirectory.in(Test).value.absolutePath),
nativeImageCommand := List(
sys.env.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
)
),
nativeImageTestRunOptions ++=
Seq("-o", "-R", classDirectory.in(Test).value.absolutePath),
nativeImageCommand :=
List(
sys
.env
.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
)
),
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.14" % "test"
)
.enablePlugins(NativeImagePlugin)
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class Hello6Spec extends AnyFlatSpec {
StandardOpenOption.APPEND
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("org.scalameta" % "sbt-native-image" % sys.props("plugin.version"))
addSbtPlugin("org.scalameta" % "sbt-native-image" % sys.props("plugin.version"))
26 changes: 15 additions & 11 deletions plugin/src/sbt-test/sbt-native-image/agent/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ lazy val example = project
.settings(
scalaVersion := "2.12.12",
mainClass.in(Compile) := Some("example.Hello3"),
nativeImageOptions ++= Seq(
"--no-fallback",
s"-H:ReflectionConfigurationFiles=${ target.value / "native-image-configs" / "reflect-config.json" }"
),
nativeImageCommand := List(
sys.env.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
nativeImageOptions ++=
Seq(
"--no-fallback",
s"-H:ReflectionConfigurationFiles=${target.value / "native-image-configs" / "reflect-config.json"}"
),
nativeImageCommand :=
List(
sys
.env
.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
)
)
)
)
.enablePlugins(NativeImagePlugin)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("org.scalameta" % "sbt-native-image" % sys.props("plugin.version"))
addSbtPlugin("org.scalameta" % "sbt-native-image" % sys.props("plugin.version"))
27 changes: 15 additions & 12 deletions plugin/src/sbt-test/sbt-native-image/basic-test/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ lazy val example = project
.settings(
scalaVersion := "2.12.12",
mainClass.in(Compile) := Some("example.Hello4"),
nativeImageCommand := List(
sys.env.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
)
),
nativeImageTestOptions ++= Seq(
"--initialize-at-build-time=scala.collection.immutable.VM"
),
nativeImageCommand :=
List(
sys
.env
.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
)
),
nativeImageTestOptions ++=
Seq("--initialize-at-build-time=scala.collection.immutable.VM"),
mainClass.in(Test) := Some("org.scalatest.tools.Runner"),
nativeImageTestRunOptions ++= Seq("-o", "-R", classDirectory.in(Test).value.absolutePath),
nativeImageTestRunOptions ++=
Seq("-o", "-R", classDirectory.in(Test).value.absolutePath),
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.14" % "test"
)
.enablePlugins(NativeImagePlugin)
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class Hello4Spec extends AnyFlatSpec {
StandardOpenOption.APPEND
)
}
}
}
17 changes: 10 additions & 7 deletions plugin/src/sbt-test/sbt-native-image/basic/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ lazy val example = project
.settings(
scalaVersion := "2.12.12",
mainClass.in(Compile) := Some("example.Hello2"),
nativeImageCommand := List(
sys.env.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
nativeImageCommand :=
List(
sys
.env
.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
)
)
)
)
.enablePlugins(NativeImagePlugin)
36 changes: 17 additions & 19 deletions plugin/src/sbt-test/sbt-native-image/cross-build-test/build.sbt
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
lazy val example = project
.settings(
crossScalaVersions := List(
"2.11.10",
"2.12.10",
"2.12.12",
"2.13.1",
"2.13.3"
),
crossScalaVersions :=
List("2.11.10", "2.12.10", "2.12.12", "2.13.1", "2.13.3"),
mainClass.in(Compile) := Some("example.Hello5"),
nativeImageTestOptions ++= Seq(
"--initialize-at-build-time=scala.collection.immutable.VM"
),
nativeImageTestOptions ++=
Seq("--initialize-at-build-time=scala.collection.immutable.VM"),
mainClass.in(Test) := Some("org.scalatest.tools.Runner"),
nativeImageTestRunOptions ++= Seq("-o", "-R", classDirectory.in(Test).value.absolutePath),
nativeImageCommand := List(
sys.env.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
)
),
nativeImageTestRunOptions ++=
Seq("-o", "-R", classDirectory.in(Test).value.absolutePath),
nativeImageCommand :=
List(
sys
.env
.getOrElse(
"NATIVE_IMAGE_COMMAND",
"missing environment variable 'NATIVE_IMAGE_COMMAND'. " +
"To fix this problem, manually install GraalVM native-image and update the environment " +
"variable to point to the absolute path of this binary."
)
),
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.14" % "test"
)
.enablePlugins(NativeImagePlugin)
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class Hello5Spec extends AnyFlatSpec {
StandardOpenOption.APPEND
)
}
}
}
8 changes: 1 addition & 7 deletions plugin/src/sbt-test/sbt-native-image/cross-build/build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
enablePlugins(NativeImagePlugin)
nativeImageOptions += "--no-fallback"
crossScalaVersions := List(
"2.11.10",
"2.12.10",
"2.12.12",
"2.13.1",
"2.13.3"
)
crossScalaVersions := List("2.11.10", "2.12.10", "2.12.12", "2.13.1", "2.13.3")
mainClass.in(Compile) := Some("Prog")
TaskKey[Unit]("check") := {
val binary = nativeImage.value
Expand Down

0 comments on commit 5f0a1fa

Please sign in to comment.