diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-18 00:55:39 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-18 00:55:39 -0800 |
commit | b83546cacea1292af3d4ae8e8c349f529b201ed2 (patch) | |
tree | 6ece81a3a95dd2fe38ad02914b4937f1e3517c22 | |
parent | a66bb3e3903e5996d0e99f26b23d5f65ab748289 (diff) | |
download | mill-b83546cacea1292af3d4ae8e8c349f529b201ed2.tar.gz mill-b83546cacea1292af3d4ae8e8c349f529b201ed2.tar.bz2 mill-b83546cacea1292af3d4ae8e8c349f529b201ed2.zip |
- Swap `Task.traverse` implementation to match behavior of other `traverse` implementations, added a `Task.sequence` that does what `traverse` used to do
- Added a `test.sh` script to easily kick off self-hosted unit test runs
- Tweak `ScalaModule` to fall back to the old behavior of including the transitive classpath during compilation
-rwxr-xr-x | build.sc | 4 | ||||
-rw-r--r-- | core/src/main/scala/mill/define/Task.scala | 8 | ||||
-rw-r--r-- | scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala | 29 | ||||
-rwxr-xr-x | test.sh | 19 |
4 files changed, 39 insertions, 21 deletions
@@ -106,7 +106,7 @@ object ScalaPlugin extends MillModule { def projectDeps = Seq(Core) def basePath = pwd / 'scalaplugin - def bridgeCompiles = mill.define.Task.traverse(bridges.items.map(_._2.compile)) + def bridgeCompiles = mill.define.Task.traverse(bridges.items)(_._2.compile) def testArgs = T{ val bridgeVersions = bridges.items.map(_._1.head.toString) @@ -122,7 +122,7 @@ object ScalaPlugin extends MillModule { val assemblyProjects = Seq(ScalaPlugin) -def assemblyClasspath = mill.define.Task.traverse(assemblyProjects.map(_.assemblyClasspath)) +def assemblyClasspath = mill.define.Task.traverse(assemblyProjects)(_.assemblyClasspath) def assemblyBase(classpath: Seq[Path], extraArgs: String) (implicit ctx: mill.util.Ctx.DestCtx) = { diff --git a/core/src/main/scala/mill/define/Task.scala b/core/src/main/scala/mill/define/Task.scala index 8393acfb..d8ca8499 100644 --- a/core/src/main/scala/mill/define/Task.scala +++ b/core/src/main/scala/mill/define/Task.scala @@ -182,10 +182,12 @@ object Task { } - def traverse[T](source: Seq[Task[T]]) = { - new Traverse[T](source) + def traverse[T, V](source: Seq[T])(f: T => Task[V]) = { + new Sequence[V](source.map(f)) } - class Traverse[+T](inputs0: Seq[Task[T]]) extends Task[Seq[T]]{ + def sequence[T](source: Seq[Task[T]]) = new Sequence[T](source) + + class Sequence[+T](inputs0: Seq[Task[T]]) extends Task[Seq[T]]{ val inputs = inputs0 def evaluate(args: Ctx) = { for (i <- 0 until args.length) diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala index 1ba15061..9f9425a4 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala @@ -78,21 +78,18 @@ trait ScalaModule extends Module with TaskModule{ outer => def upstreamRunClasspath = T{ - Task.traverse( - for (p <- projectDeps) - yield T.task(p.runDepClasspath() ++ Seq(p.compile().classes, p.resources())) + Task.traverse(projectDeps)(p => + T.task(p.runDepClasspath() ++ Seq(p.compile().classes, p.resources())) ) } - def upstreamCompileDepClasspath = T{ - Task.traverse(projectDeps.map(_.externalCompileDepClasspath)) - } - def upstreamCompileDepSources = T{ - Task.traverse(projectDeps.map(_.externalCompileDepSources)) - } - def upstreamCompileOutput = T{ - Task.traverse(projectDeps.map(_.compile)) + Task.traverse(projectDeps)(_.compile) + } + def upstreamCompileClasspath = T{ + externalCompileDepClasspath() ++ + upstreamCompileOutput().map(_.classes) ++ + Task.traverse(projectDeps)(_.compileDepClasspath)().flatten } def resolveDeps(deps: Task[Seq[Dep]], sources: Boolean = false) = T.task{ @@ -105,13 +102,14 @@ trait ScalaModule extends Module with TaskModule{ outer => ) } def externalCompileDepClasspath: T[Seq[PathRef]] = T{ - upstreamCompileDepClasspath().flatten ++ + Task.traverse(projectDeps)(_.externalCompileDepClasspath)().flatten ++ resolveDeps( T.task{ivyDeps() ++ compileIvyDeps() ++ scalaCompilerIvyDeps(scalaVersion())} )() } + def externalCompileDepSources: T[Seq[PathRef]] = T{ - upstreamCompileDepSources().flatten ++ + Task.traverse(projectDeps)(_.externalCompileDepSources)().flatten ++ resolveDeps( T.task{ivyDeps() ++ compileIvyDeps() ++ scalaCompilerIvyDeps(scalaVersion())}, sources = true @@ -122,9 +120,8 @@ trait ScalaModule extends Module with TaskModule{ outer => * might be less than the runtime classpath */ def compileDepClasspath: T[Seq[PathRef]] = T{ - upstreamCompileOutput().map(_.classes) ++ - depClasspath() ++ - externalCompileDepClasspath() + upstreamCompileClasspath() ++ + depClasspath() } /** diff --git a/test.sh b/test.sh new file mode 100755 index 00000000..ffae4a10 --- /dev/null +++ b/test.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -eux + +# Starting from scratch... +git clean -xdf + +# First build & run tests using SBT +sbt core/test scalaplugin/test bin/test:assembly + +# Second build & run tests using Mill built using SBT +bin/target/mill run Core.test +bin/target/mill run ScalaPlugin.test +bin/target/mill run assembly + +# Third build & run tests using Mill built using Mill +out/assembly run Core.test +out/assembly run ScalaPlugin.test +out/assembly run assembly
\ No newline at end of file |