summaryrefslogtreecommitdiff
path: root/build.sbt
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-12-15 17:41:32 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-12-15 17:42:22 -0800
commit4ec6dca8c3432339620bbc6298fdf75a4b930fb4 (patch)
tree1c17bb9bb3477be1b498c72ff2c74b9d235dd4bd /build.sbt
parent3a40842d7b3aeedddb9ab5e8261dd48ea4e024b6 (diff)
downloadmill-4ec6dca8c3432339620bbc6298fdf75a4b930fb4.tar.gz
mill-4ec6dca8c3432339620bbc6298fdf75a4b930fb4.tar.bz2
mill-4ec6dca8c3432339620bbc6298fdf75a4b930fb4.zip
First pass at using a compiler plugin to remove the need for the `override` keyword when overriding a field within a `mill.Module`
This only applies to `mill.Module`s, not overrides elsewhere which still require the keyword. `mill.Module`s tend to have lots and lots of overriding, so the keyword is basically noise. Also includes the necessary build changes to enable the locally-built Scalac plugin when compiling the test suite. Note that no changes are necessary for the executable assembly, because the `scalac-plugin.xml` will be included in the assembly and get picked up by the Ammonite scalac plugin classloader automatically
Diffstat (limited to 'build.sbt')
-rw-r--r--build.sbt28
1 files changed, 27 insertions, 1 deletions
diff --git a/build.sbt b/build.sbt
index 57035a6e..7069a5c5 100644
--- a/build.sbt
+++ b/build.sbt
@@ -19,7 +19,17 @@ val sharedSettings = Seq(
IO.write(file, """object amm extends App { ammonite.Main().run() }""")
Seq(file)
}.taskValue
+)
+val pluginSettings = Seq(
+ scalacOptions in Test ++= {
+ val jarFile = (packageBin in (plugin, Compile)).value
+ val addPlugin = "-Xplugin:" + jarFile.getAbsolutePath
+ // add plugin timestamp to compiler options to trigger recompile of
+ // main after editing the plugin. (Otherwise a 'clean' is needed.)
+ val dummy = "-Jdummy=" + jarFile.lastModified
+ Seq(addPlugin, dummy)
+ }
)
def bridge(bridgeVersion: String) = Project(
@@ -71,8 +81,10 @@ lazy val bridge2_12_3 = bridge("2.12.3")
lazy val bridge2_12_4 = bridge("2.12.4")
lazy val core = project
+ .dependsOn(plugin)
.settings(
sharedSettings,
+ pluginSettings,
name := "mill-core",
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
@@ -84,25 +96,39 @@ lazy val core = project
)
)
+lazy val plugin = project
+ .settings(
+ sharedSettings,
+ libraryDependencies ++= Seq(
+ "org.scala-lang" % "scala-compiler" % scalaVersion.value,
+ "com.lihaoyi" %% "sourcecode" % "0.1.4"
+ ),
+ publishArtifact in Compile := false
+ )
+
val bridgeProps = Def.task{
val mapping = Map(
"MILL_COMPILER_BRIDGE_2_10_6" -> (packageBin in (bridge2_10_6, Compile)).value.absolutePath,
"MILL_COMPILER_BRIDGE_2_11_8" -> (packageBin in (bridge2_11_8, Compile)).value.absolutePath,
"MILL_COMPILER_BRIDGE_2_11_11" -> (packageBin in (bridge2_11_11, Compile)).value.absolutePath,
"MILL_COMPILER_BRIDGE_2_12_3" -> (packageBin in (bridge2_12_3, Compile)).value.absolutePath,
- "MILL_COMPILER_BRIDGE_2_12_4" -> (packageBin in (bridge2_12_4, Compile)).value.absolutePath
+ "MILL_COMPILER_BRIDGE_2_12_4" -> (packageBin in (bridge2_12_4, Compile)).value.absolutePath,
+ "MILL_COMPILER_PLUGIN" -> (packageBin in (plugin, Compile)).value
)
for((k, v) <- mapping) yield s"-D$k=$v"
}
+
lazy val scalaplugin = project
.dependsOn(core % "compile->compile;test->test")
.settings(
sharedSettings,
+ pluginSettings,
name := "mill-scalaplugin",
fork in Test := true,
baseDirectory in Test := (baseDirectory in Test).value / "..",
javaOptions in Test := bridgeProps.value.toSeq
)
+
lazy val bin = project
.dependsOn(scalaplugin)
.settings(