diff --git a/plugin/src/main/scala/sbtnativeimage/NativeImagePlugin.scala b/plugin/src/main/scala/sbtnativeimage/NativeImagePlugin.scala index 0279690..9b40827 100644 --- a/plugin/src/main/scala/sbtnativeimage/NativeImagePlugin.scala +++ b/plugin/src/main/scala/sbtnativeimage/NativeImagePlugin.scala @@ -17,6 +17,7 @@ import sbt._ import sbt.plugins.JvmPlugin import sbt.complete.DefaultParsers._ import java.nio.file.Paths +import scala.util.Try object NativeImagePlugin extends AutoPlugin { override def requires = JvmPlugin @@ -79,10 +80,7 @@ object NativeImagePlugin extends AutoPlugin { out.toFile } override lazy val projectSettings: Seq[Def.Setting[_]] = List( - libraryDependencies ++= { - if (scalaVersion.value.startsWith("2.11")) Nil - else List("org.scalameta" %% "svm-subs" % nativeImageVersion.value) - }, + libraryDependencies += "org.scalameta" % "svm-subs" % "101.0.0", target.in(NativeImage) := target.in(Compile).value / "native-image", target.in(NativeImageInternal) := diff --git a/plugin/src/sbt-test/sbt-native-image/cross-build/Prog.scala b/plugin/src/sbt-test/sbt-native-image/cross-build/Prog.scala new file mode 100644 index 0000000..75c3080 --- /dev/null +++ b/plugin/src/sbt-test/sbt-native-image/cross-build/Prog.scala @@ -0,0 +1,3 @@ +object Prog { + def main(args: Array[String]): Unit = println(List(1, 2, 3).toString) +} diff --git a/plugin/src/sbt-test/sbt-native-image/cross-build/build.sbt b/plugin/src/sbt-test/sbt-native-image/cross-build/build.sbt new file mode 100644 index 0000000..ceecc41 --- /dev/null +++ b/plugin/src/sbt-test/sbt-native-image/cross-build/build.sbt @@ -0,0 +1,15 @@ +enablePlugins(NativeImagePlugin) +nativeImageOptions += "--no-fallback" +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 + val output = scala.sys.process.Process(List(binary.toString)).!!.trim + assert(output == "List(1, 2, 3)", s"obtained: $output") +} diff --git a/plugin/src/sbt-test/sbt-native-image/cross-build/example/src/main/scala/example/Hello2.scala b/plugin/src/sbt-test/sbt-native-image/cross-build/example/src/main/scala/example/Hello2.scala new file mode 100644 index 0000000..a29bfcd --- /dev/null +++ b/plugin/src/sbt-test/sbt-native-image/cross-build/example/src/main/scala/example/Hello2.scala @@ -0,0 +1,15 @@ +package example + +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.charset.StandardCharsets + +object Hello2 { + def main(args: Array[String]): Unit = { + val text = List(1, 2, 3).toString() + "\n" + Files.write( + Paths.get("hello2.obtained"), + text.getBytes(StandardCharsets.UTF_8) + ) + } +} diff --git a/plugin/src/sbt-test/sbt-native-image/cross-build/project/build.properties b/plugin/src/sbt-test/sbt-native-image/cross-build/project/build.properties new file mode 100644 index 0000000..0837f7a --- /dev/null +++ b/plugin/src/sbt-test/sbt-native-image/cross-build/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.3.13 diff --git a/plugin/src/sbt-test/sbt-native-image/cross-build/project/plugins.sbt b/plugin/src/sbt-test/sbt-native-image/cross-build/project/plugins.sbt new file mode 100644 index 0000000..f8040a6 --- /dev/null +++ b/plugin/src/sbt-test/sbt-native-image/cross-build/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("org.scalameta" % "sbt-native-image" % sys.props("plugin.version")) diff --git a/plugin/src/sbt-test/sbt-native-image/cross-build/test b/plugin/src/sbt-test/sbt-native-image/cross-build/test new file mode 100644 index 0000000..82db052 --- /dev/null +++ b/plugin/src/sbt-test/sbt-native-image/cross-build/test @@ -0,0 +1 @@ +> +check