summaryrefslogtreecommitdiff
path: root/build.sbt
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-12-28 16:13:20 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-12-28 16:14:37 -0800
commitd44acfa600ddb0b91197285528de6a60f6266fb5 (patch)
tree0a802fbab97b421a8b572fe79c21ff8a2f274114 /build.sbt
parent9f2f37602b6e93f5e2900439d0c66efd29a30862 (diff)
downloadmill-d44acfa600ddb0b91197285528de6a60f6266fb5.tar.gz
mill-d44acfa600ddb0b91197285528de6a60f6266fb5.tar.bz2
mill-d44acfa600ddb0b91197285528de6a60f6266fb5.zip
Convert `build.sbt` to use ivy-resolved Ammonite to run `shared.sc`, instead of shelling out
Diffstat (limited to 'build.sbt')
-rw-r--r--build.sbt65
1 files changed, 33 insertions, 32 deletions
diff --git a/build.sbt b/build.sbt
index 7874c894..31a21556 100644
--- a/build.sbt
+++ b/build.sbt
@@ -15,27 +15,6 @@ val sharedSettings = Seq(
addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.7")
)
-val coreSettings = Seq(
- sourceGenerators in Compile += Def.task {
- import sys.process._
- val dir = (sourceManaged in Compile).value
- if (!dir.exists()) {
- IO.createDirectory(dir)
- Seq("amm", "shared.sc", "generateSources", dir.toString).!
- }
- IO.listFiles(dir).toSeq
- }.taskValue,
-
- sourceGenerators in Test += Def.task {
- import sys.process._
- val dir = (sourceManaged in Test).value
- if (!dir.exists()) {
- IO.createDirectory(dir)
- Seq("amm", "shared.sc", "generateTests", dir.toString).!
- }
- IO.listFiles(dir).toSeq
- }.taskValue
-)
val pluginSettings = Seq(
scalacOptions in Test ++= {
@@ -48,6 +27,26 @@ val pluginSettings = Seq(
}
)
+lazy val ammoniteRunner = project.settings(
+ libraryDependencies +=
+ "com.lihaoyi" % "ammonite" % "1.0.3" cross CrossVersion.full
+)
+
+
+def ammoniteRun(hole: SettingKey[File], args: String => List[String]) = Def.task{
+ if (!hole.value.exists()) {
+ IO.createDirectory(hole.value)
+ (runner in(ammoniteRunner, Compile)).value.run(
+ "ammonite.Main",
+ (dependencyClasspath in(ammoniteRunner, Compile)).value.files,
+ args(hole.value.toString),
+ streams.value.log
+ )
+ }
+ (hole.value ** "*.scala").get
+}
+
+
def bridge(bridgeVersion: String) = Project(
id = "bridge" + bridgeVersion.replace('.', '_'),
base = file("bridge/" + bridgeVersion.replace('.', '_')),
@@ -60,17 +59,13 @@ def bridge(bridgeVersion: String) = Project(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.scala-sbt" % "compiler-interface" % "1.0.5"
),
- (sourceGenerators in Compile) += Def.task{
- import sys.process._
- val dir = (sourceManaged in Compile).value
- if (!dir.exists()) {
- IO.createDirectory(dir)
- Seq("amm", "shared.sc", "downloadBridgeSource", dir.toString, bridgeVersion).!
- }
- (dir ** "*.scala").get
- }.taskValue
+ (sourceGenerators in Compile) += ammoniteRun(
+ sourceManaged in Compile,
+ List("shared.sc", "downloadBridgeSource", _, bridgeVersion)
+ ).taskValue
)
)
+
lazy val bridge2_10_6 = bridge("2.10.6")
lazy val bridge2_11_8 = bridge("2.11.8")
//lazy val bridge2_11_9 = bridge("2.11.9")
@@ -86,7 +81,6 @@ lazy val core = project
.dependsOn(plugin)
.settings(
sharedSettings,
- coreSettings,
pluginSettings,
name := "mill-core",
libraryDependencies ++= Seq(
@@ -96,7 +90,14 @@ lazy val core = project
"com.lihaoyi" % "ammonite" % "1.0.3-20-75e58ac" cross CrossVersion.full,
"org.scala-sbt" %% "zinc" % "1.0.5",
"org.scala-sbt" % "test-interface" % "1.0"
- )
+ ),
+ sourceGenerators in Compile += {
+ ammoniteRun(sourceManaged in Compile, List("shared.sc", "generateSources", _)).taskValue
+ },
+
+ sourceGenerators in Test += {
+ ammoniteRun(sourceManaged in Test, List("shared.sc", "generateTests", _)).taskValue
+ }
)
lazy val plugin = project