diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 641856be9..dd26150e1 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -1329,16 +1329,24 @@ object Classpaths (base * (filter -- excl) +++ (base / config.name).descendantsExcept(filter, excl)).classpath - def autoPlugins(report: UpdateReport): Seq[String] = + @deprecated("Specify the classpath that includes internal dependencies", "0.13.0") + def autoPlugins(report: UpdateReport): Seq[String] = autoPlugins(report, Nil) + def autoPlugins(report: UpdateReport, internalPluginClasspath: Seq[File]): Seq[String] = { - val pluginClasspath = report matching configurationFilter(CompilerPlugin.name) - classpath.ClasspathUtilities.compilerPlugins(pluginClasspath).map("-Xplugin:" + _.getAbsolutePath).toSeq + val pluginClasspath = report.matching(configurationFilter(CompilerPlugin.name)) ++ internalPluginClasspath + val plugins = classpath.ClasspathUtilities.compilerPlugins(pluginClasspath) + plugins.map("-Xplugin:" + _.getAbsolutePath).toSeq } + private[this] lazy val internalCompilerPluginClasspath: Initialize[Task[Classpath]] = + (thisProjectRef, settingsData, buildDependencies) flatMap { (ref, data, deps) => + internalDependencies0(ref, CompilerPlugin, CompilerPlugin, data, deps) + } + lazy val compilerPluginConfig = Seq( scalacOptions := { val options = scalacOptions.value - if(autoCompilerPlugins.value) options ++ autoPlugins(update.value) else options + if(autoCompilerPlugins.value) options ++ autoPlugins(update.value, internalCompilerPluginClasspath.value.files) else options } ) @deprecated("Doesn't properly handle non-standard Scala organizations.", "0.13.0") diff --git a/sbt/src/sbt-test/compiler-project/src-dep-plugin/build.sbt b/sbt/src/sbt-test/compiler-project/src-dep-plugin/build.sbt new file mode 100644 index 000000000..4871bbf58 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/src-dep-plugin/build.sbt @@ -0,0 +1,5 @@ +import Configurations.{CompilerPlugin => CPlugin} + +lazy val use = project.dependsOn(file("def") % CPlugin).settings( + autoCompilerPlugins := true +) diff --git a/sbt/src/sbt-test/compiler-project/src-dep-plugin/changes/DemoPlugin.scala b/sbt/src/sbt-test/compiler-project/src-dep-plugin/changes/DemoPlugin.scala new file mode 100644 index 000000000..7fdbf420a --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/src-dep-plugin/changes/DemoPlugin.scala @@ -0,0 +1,10 @@ +package demo + + import scala.tools.nsc.{Global, plugins} + +class DemoPlugin(val global: Global) extends plugins.Plugin +{ + val name = "demo-plugin" + val description = "Throws an error" + val components = error("The plugin was successfully registered.") +} diff --git a/sbt/src/sbt-test/compiler-project/src-dep-plugin/changes/scalac-plugin.xml b/sbt/src/sbt-test/compiler-project/src-dep-plugin/changes/scalac-plugin.xml new file mode 100644 index 000000000..542c3106c --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/src-dep-plugin/changes/scalac-plugin.xml @@ -0,0 +1,4 @@ + + demo + demo.DemoPlugin + diff --git a/sbt/src/sbt-test/compiler-project/src-dep-plugin/def/build.sbt b/sbt/src/sbt-test/compiler-project/src-dep-plugin/def/build.sbt new file mode 100644 index 000000000..0830ec789 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/src-dep-plugin/def/build.sbt @@ -0,0 +1,9 @@ +organization := "org.example" + +name := "demo-compiler-plugin" + +version := "0.1" + +libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided" + +exportJars := true \ No newline at end of file diff --git a/sbt/src/sbt-test/compiler-project/src-dep-plugin/test b/sbt/src/sbt-test/compiler-project/src-dep-plugin/test new file mode 100644 index 000000000..29a4f221d --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/src-dep-plugin/test @@ -0,0 +1,10 @@ +# compilation should succeed on the trivial source file in use/ +> use/compile + +# add the plugin +$ copy-file changes/scalac-plugin.xml def/src/main/resources/scalac-plugin.xml +$ copy-file changes/DemoPlugin.scala def/DemoPlugin.scala + +# if the plugin is successfully registered it will generate an error on construction +> use/clean +-> use/compile diff --git a/sbt/src/sbt-test/compiler-project/src-dep-plugin/use/A.scala b/sbt/src/sbt-test/compiler-project/src-dep-plugin/use/A.scala new file mode 100644 index 000000000..69c493db2 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/src-dep-plugin/use/A.scala @@ -0,0 +1 @@ +object A diff --git a/src/sphinx/Community/ChangeSummary_0.13.0.rst b/src/sphinx/Community/ChangeSummary_0.13.0.rst index 894ca5ef6..99ac70469 100644 --- a/src/sphinx/Community/ChangeSummary_0.13.0.rst +++ b/src/sphinx/Community/ChangeSummary_0.13.0.rst @@ -44,6 +44,7 @@ Improvements - Tasks that need a directory for storing cache information can now use the ``cacheDirectory`` method on ``streams``. This supersedes the ``cacheDirectory`` setting. - The environment variables used when forking ``run`` and ``test`` may be set via ``envVars``, which is a ``Task[Map[String,String]]``. (gh-665) - Restore class files after an unsuccessful compilation. This is useful when an error occurs in a later incremental step that requires a fix in the originally changed files. +- ``autoCompilerPlugins`` now supports compiler plugins defined in a internal dependency. The plugin project must define ``exportJars := true``. Depend on the plugin with ``...dependsOn(... % Configurations.CompilerPlugin)``. Other -----