aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2017-08-12 16:17:13 -0700
committerJakob Odersky <jakob@odersky.com>2017-08-26 16:08:18 -0700
commit10417b902af043bd256609762e0764320ec94f24 (patch)
tree360b49b4e33235926eb640c66ab59b6a0820fd13
parent3d2c3d07cab51ab0cb9cec5edfe14e3c37c8e68e (diff)
downloadsbt-jni-10417b902af043bd256609762e0764320ec94f24.tar.gz
sbt-jni-10417b902af043bd256609762e0764320ec94f24.tar.bz2
sbt-jni-10417b902af043bd256609762e0764320ec94f24.zip
Workaround ignored runtime dependency bug
-rw-r--r--plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/RunDependencyFixPlugin.scala43
-rw-r--r--plugin/src/sbt-test/sbt-jni/multiclasses/build.sbt4
-rw-r--r--plugin/src/sbt-test/sbt-jni/simple/build.sbt3
3 files changed, 48 insertions, 2 deletions
diff --git a/plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/RunDependencyFixPlugin.scala b/plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/RunDependencyFixPlugin.scala
new file mode 100644
index 0000000..921caac
--- /dev/null
+++ b/plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/RunDependencyFixPlugin.scala
@@ -0,0 +1,43 @@
+package ch.jodersky.sbt.jni.plugins
+
+import sbt._
+import sbt.Keys._
+import java.io.File
+
+/** Adds an extension method `dependsOnRun` to projects, to work around an sbt
+ * bug https://github.com/sbt/sbt/issues/3425 */
+object RunDependencyFixPlugin extends AutoPlugin {
+
+ override def requires = plugins.CorePlugin
+ override def trigger = allRequirements
+
+ object autoImport {
+
+ val runClasspath = taskKey[Seq[sbt.internal.util.Attributed[File]]]("Classpath used in run task")
+
+ def dependsOnRunSettings(project: Project) = Seq(
+ runClasspath in Compile ++= (runClasspath in Compile in project).value,
+ run := {
+ Defaults.runTask(
+ runClasspath in Compile,
+ mainClass in Compile in run,
+ runner in run
+ ).evaluated
+ }
+ )
+
+ implicit class RichProject(project: Project) {
+ @deprecated("Temporary fix for https://github.com/sbt/sbt/issues/3425", "1.3.0")
+ def dependsOnRun(other: Project) = {
+ project.settings(dependsOnRunSettings(other): _*)
+ }
+ }
+
+ }
+ import autoImport._
+
+ override def projectSettings = Seq(
+ runClasspath in Compile := (fullClasspath in Compile).value
+ )
+
+}
diff --git a/plugin/src/sbt-test/sbt-jni/multiclasses/build.sbt b/plugin/src/sbt-test/sbt-jni/multiclasses/build.sbt
index d12a711..c1352d9 100644
--- a/plugin/src/sbt-test/sbt-jni/multiclasses/build.sbt
+++ b/plugin/src/sbt-test/sbt-jni/multiclasses/build.sbt
@@ -5,7 +5,9 @@ lazy val root = (project in file(".")).
lazy val core = (project in file("core")).
dependsOn(native1 % Runtime).
- dependsOn(native2 % Runtime)
+ dependsOn(native2 % Runtime).
+ dependsOnRun(native1).
+ dependsOnRun(native2)
lazy val native1 = (project in file("native1")).
settings(sourceDirectory in nativeCompile := sourceDirectory.value).
diff --git a/plugin/src/sbt-test/sbt-jni/simple/build.sbt b/plugin/src/sbt-test/sbt-jni/simple/build.sbt
index cd490b0..b3d441a 100644
--- a/plugin/src/sbt-test/sbt-jni/simple/build.sbt
+++ b/plugin/src/sbt-test/sbt-jni/simple/build.sbt
@@ -6,7 +6,8 @@ lazy val root = (project in file(".")).
lazy val core = (project in file("core")).
settings(libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test").
settings(target in javah := (sourceDirectory in nativeCompile in native).value / "include").
- dependsOn(native % Runtime)
+ dependsOn(native % Runtime).
+ dependsOnRun(native)
lazy val native = (project in file("native")).
settings(sourceDirectory in nativeCompile := sourceDirectory.value).