aboutsummaryrefslogtreecommitdiff
path: root/plugin/src/main
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 /plugin/src/main
parent3d2c3d07cab51ab0cb9cec5edfe14e3c37c8e68e (diff)
downloadsbt-jni-10417b902af043bd256609762e0764320ec94f24.tar.gz
sbt-jni-10417b902af043bd256609762e0764320ec94f24.tar.bz2
sbt-jni-10417b902af043bd256609762e0764320ec94f24.zip
Workaround ignored runtime dependency bug
Diffstat (limited to 'plugin/src/main')
-rw-r--r--plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/RunDependencyFixPlugin.scala43
1 files changed, 43 insertions, 0 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
+ )
+
+}