aboutsummaryrefslogtreecommitdiff
path: root/plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/RunDependencyFixPlugin.scala
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/src/main/scala/ch/jodersky/sbt/jni/plugins/RunDependencyFixPlugin.scala')
-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
+ )
+
+}