summaryrefslogtreecommitdiff
path: root/build.sc
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-12-12 22:15:38 +0800
committerGitHub <noreply@github.com>2018-12-12 22:15:38 +0800
commitea7fceb6e56f53bde3517586dfc57e10a605a524 (patch)
treecf2e4b7a403f8bcbcf3d1c4c45a8abd315cbefe6 /build.sc
parentd0e1b572e88d311e1aee23d92e0384a81de4bcb6 (diff)
downloadmill-ea7fceb6e56f53bde3517586dfc57e10a605a524.tar.gz
mill-ea7fceb6e56f53bde3517586dfc57e10a605a524.tar.bz2
mill-ea7fceb6e56f53bde3517586dfc57e10a605a524.zip
First pass at splitting out worker-api from mill core. (#504)
This reduces the {scala,scalajs,scalanative}-worker dependency from the entirety of Mill to a much narrower `mill.api` module. This reduces the amount of classpath pollution within these workers, should mean they're much faster to download the first time, and reduces the amount of random junk they would pull in if they were to be used outside of the Mill project. The interactions between the various *Modules and their *WorkerImpls has been narrowed down to the `*.api` modules, which only depend on other `*.api` modules. A lot of things have been moved around; user code is unlikely to break, but it's possible some will if it references classes that have been moved around. Forwarders have been left for the few internal classes that Mill uses in it's own `build.sc`, to support bootstrapping. Third-party code which breaks should be a straightforward to fix just by updating imports The `*.api` modules have minimal dependencies (mostly uPickle and os-lib) and minimal code. There is still a bunch of implementation code in there: some of it defining data-types that are commonly sent across the module/worker interface (`Agg`, `PathRef`, ...), and some of it just general helper functions that are needed both in modules and workers. The latter code isn't strictly API definitions, but for now is small enough it's not worth splitting into it's own module
Diffstat (limited to 'build.sc')
-rwxr-xr-xbuild.sc47
1 files changed, 31 insertions, 16 deletions
diff --git a/build.sc b/build.sc
index aad309a8..1cbbe992 100755
--- a/build.sc
+++ b/build.sc
@@ -26,8 +26,7 @@ trait MillPublishModule extends PublishModule{
def javacOptions = Seq("-source", "1.8", "-target", "1.8")
}
-
-trait MillModule extends MillPublishModule with ScalaModule{ outer =>
+trait MillApiModule extends MillPublishModule with ScalaModule{
def scalaVersion = T{ "2.12.6" }
def compileIvyDeps = Agg(ivy"com.lihaoyi::acyclic:0.1.7")
def scalacOptions = Seq("-P:acyclic:force")
@@ -35,6 +34,8 @@ trait MillModule extends MillPublishModule with ScalaModule{ outer =>
def repositories = super.repositories ++ Seq(
MavenRepository("https://oss.sonatype.org/content/repositories/releases")
)
+}
+trait MillModule extends MillApiModule{ outer =>
def scalacPluginClasspath =
super.scalacPluginClasspath() ++ Seq(main.moduledefs.jar())
@@ -77,9 +78,14 @@ object main extends MillModule {
Seq(PathRef(shared.generateCoreTestSources(T.ctx().dest)))
}
}
-
+ object api extends MillApiModule{
+ def ivyDeps = Agg(
+ ivy"com.lihaoyi::os-lib:0.2.6",
+ ivy"com.lihaoyi::upickle:0.7.1",
+ )
+ }
object core extends MillModule {
- def moduleDeps = Seq(moduledefs)
+ def moduleDeps = Seq(moduledefs, api)
def compileIvyDeps = Agg(
ivy"org.scala-lang:scala-reflect:${scalaVersion()}"
@@ -134,7 +140,7 @@ object main extends MillModule {
object scalalib extends MillModule {
- def moduleDeps = Seq(main)
+ def moduleDeps = Seq(main, scalalib.api)
def ivyDeps = Agg(
ivy"org.scala-sbt:test-interface:1.0"
@@ -172,23 +178,27 @@ object scalalib extends MillModule {
)
}
}
- object worker extends MillModule{
- def moduleDeps = Seq(main, scalalib)
+ object api extends MillApiModule{
+ def moduleDeps = Seq(main.api)
+ }
+ object worker extends MillApiModule{
+
+ def moduleDeps = Seq(scalalib.api)
def ivyDeps = Agg(
// Keep synchronized with zinc in Versions.scala
ivy"org.scala-sbt::zinc:1.2.1"
)
- def testArgs = Seq(
+ def testArgs = T{Seq(
"-DMILL_SCALA_WORKER=" + runClasspath().map(_.path).mkString(",")
- )
+ )}
}
}
object scalajslib extends MillModule {
- def moduleDeps = Seq(scalalib)
+ def moduleDeps = Seq(scalalib, scalajslib.api)
def testArgs = T{
val mapping = Map(
@@ -201,9 +211,12 @@ object scalajslib extends MillModule {
(for((k, v) <- mapping.toSeq) yield s"-D$k=$v")
}
+ object api extends MillApiModule{
+ def moduleDeps = Seq(main.core)
+ }
object worker extends Cross[WorkerModule]("0.6", "1.0")
- class WorkerModule(scalajsBinary: String) extends MillModule{
- def moduleDeps = Seq(scalajslib)
+ class WorkerModule(scalajsBinary: String) extends MillApiModule{
+ def moduleDeps = Seq(scalajslib.api)
def ivyDeps = scalajsBinary match {
case "0.6" =>
Agg(
@@ -257,7 +270,7 @@ object contrib extends MillModule {
object scalanativelib extends MillModule {
- def moduleDeps = Seq(scalalib)
+ def moduleDeps = Seq(scalalib, scalanativelib.api)
def scalacOptions = Seq[String]() // disable -P:acyclic:force
@@ -273,11 +286,13 @@ object scalanativelib extends MillModule {
scalalib.backgroundwrapper.testArgs() ++
(for((k, v) <- mapping.toSeq) yield s"-D$k=$v")
}
-
+ object api extends MillApiModule{
+ def moduleDeps = Seq(main.core)
+ }
object worker extends Cross[WorkerModule]("0.3")
- class WorkerModule(scalaNativeBinary: String) extends MillModule {
+ class WorkerModule(scalaNativeBinary: String) extends MillApiModule {
def scalaNativeVersion = T{ "0.3.8" }
- def moduleDeps = Seq(scalanativelib)
+ def moduleDeps = Seq(scalanativelib.api)
def ivyDeps = scalaNativeBinary match {
case "0.3" =>
Agg(