diff options
-rwxr-xr-x | build.sc | 49 | ||||
-rw-r--r-- | core/src/main/scala/mill/define/Task.scala | 14 | ||||
-rw-r--r-- | core/src/main/scala/mill/eval/PathRef.scala | 1 | ||||
-rw-r--r-- | core/src/main/scala/mill/modules/Jvm.scala | 2 | ||||
-rw-r--r-- | scalaplugin/src/main/scala/mill/scalaplugin/Subproject.scala | 6 |
5 files changed, 39 insertions, 33 deletions
@@ -10,40 +10,35 @@ import mill.scalaplugin.{TestRunner, _} @main def main(args: String*) = mill.Main(args, Build) object Build{ trait MillSubproject extends Subproject{ - def scalaVersion = T{ "2.12.4" } + def scalaVersion = "2.12.4" } object Core extends MillSubproject { - override def compileIvyDeps = T{ - Seq( - Dep.Java("org.scala-lang", "scala-reflect", scalaVersion()) - ) - } + override def compileIvyDeps = Seq( + Dep.Java("org.scala-lang", "scala-reflect", scalaVersion()) + ) - override def ivyDeps = T{ - Seq( - Dep("com.lihaoyi", "sourcecode", "0.1.4"), - Dep("com.lihaoyi", "pprint", "0.5.3"), - Dep.Point("com.lihaoyi", "ammonite", "1.0.3"), - Dep("com.typesafe.play", "play-json", "2.6.6"), - Dep("org.scala-sbt", "zinc", "1.0.3"), - Dep.Java("org.scala-sbt", "test-interface", "1.0") - ) - } + override def ivyDeps = Seq( + Dep("com.lihaoyi", "sourcecode", "0.1.4"), + Dep("com.lihaoyi", "pprint", "0.5.3"), + Dep.Point("com.lihaoyi", "ammonite", "1.0.3"), + Dep("com.typesafe.play", "play-json", "2.6.6"), + Dep("org.scala-sbt", "zinc", "1.0.3"), + Dep.Java("org.scala-sbt", "test-interface", "1.0") + ) - def basePath = T{ pwd / 'core } - override def sources = T{ pwd/'core/'src/'main/'scala } + def basePath = pwd / 'core + override def sources = PathRef(pwd/'core/'src/'main/'scala) } object CoreTests extends MillSubproject { override def projectDeps = Seq(Core) - def basePath = T{ pwd / 'scalaplugin } - override def sources = T{ pwd/'core/'src/'test/'scala } - override def ivyDeps = T{ - Seq[Dep]( - Dep("com.lihaoyi", "utest", "0.6.0") - ) - } + def basePath = pwd / 'scalaplugin + override def sources = PathRef(pwd/'core/'src/'test/'scala) + override def ivyDeps = Seq( + Dep("com.lihaoyi", "utest", "0.6.0") + ) + def test() = T.command{ TestRunner.apply( "mill.UTestFramework", @@ -55,8 +50,8 @@ object Build{ object ScalaPlugin extends MillSubproject { override def projectDeps = Seq(Core) - def basePath = T{ pwd / 'scalaplugin } - override def sources = T{ pwd/'scalaplugin/'src/'main/'scala } + def basePath = pwd / 'scalaplugin + override def sources = PathRef(pwd/'scalaplugin/'src/'main/'scala) } } diff --git a/core/src/main/scala/mill/define/Task.scala b/core/src/main/scala/mill/define/Task.scala index ad6248d9..c1568a8f 100644 --- a/core/src/main/scala/mill/define/Task.scala +++ b/core/src/main/scala/mill/define/Task.scala @@ -47,7 +47,8 @@ object Task extends Applicative.Applyer[Task, Task, Args]{ def evaluate(args: Args) = t0 } - def apply[T](t: T): Target[T] = macro targetCachedImpl[T] + implicit def apply[T](t: T): Target[T] = macro targetCachedImpl[T] + def apply[T](t: Task[T]): Target[T] = macro Cacher.impl0[Task, T] def command[T](t: T): Command[T] = macro targetCommandImpl[T] @@ -71,6 +72,17 @@ object Task extends Applicative.Applyer[Task, Task, Args]{ ) ) } + def targetCachedImpl2[T: c.WeakTypeTag, V: c.WeakTypeTag] + (c: Context) + (t: c.Expr[T]) + (f: c.Expr[T => V]): c.Expr[Target[V]] = { + import c.universe._ + c.Expr[Target[V]]( + mill.define.Cacher.wrapCached(c)( + q"""${Applicative.impl[Task, T, Args](c)(t).tree}.map($f)""" + ) + ) + } abstract class Ops[+T]{ this: Task[T] => def map[V](f: T => V) = new Task.Mapped(this, f) diff --git a/core/src/main/scala/mill/eval/PathRef.scala b/core/src/main/scala/mill/eval/PathRef.scala index 6d99ad91..5f7efe89 100644 --- a/core/src/main/scala/mill/eval/PathRef.scala +++ b/core/src/main/scala/mill/eval/PathRef.scala @@ -55,7 +55,6 @@ case class PathRef(path: ammonite.ops.Path){ } object PathRef{ - implicit def make(p: ammonite.ops.Path): PathRef = PathRef(p) private implicit val pathFormat: Format[Path] = JsonFormatters.pathFormat implicit def jsonFormatter: Format[PathRef] = Json.format } diff --git a/core/src/main/scala/mill/modules/Jvm.scala b/core/src/main/scala/mill/modules/Jvm.scala index bbaf1474..bfb7defe 100644 --- a/core/src/main/scala/mill/modules/Jvm.scala +++ b/core/src/main/scala/mill/modules/Jvm.scala @@ -64,7 +64,7 @@ object Jvm { val inputs = roots def evaluate(args: Args): PathRef = { createJar(args.dest, args.args.map(_.asInstanceOf[PathRef].path)) - args.dest + PathRef(args.dest) } } } diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/Subproject.scala b/scalaplugin/src/main/scala/mill/scalaplugin/Subproject.scala index 2dcbbe04..2fd9b2e0 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/Subproject.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/Subproject.scala @@ -110,7 +110,7 @@ object Subproject{ l } ) - outputPath + PathRef(outputPath) } def resolveDependencies(repositories: Seq[Repository], @@ -237,8 +237,8 @@ trait Subproject extends Cacher{ ) } - def sources = T[PathRef]{ basePath() / 'src } - def resources = T[PathRef]{ basePath() / 'resources } + def sources = T{ PathRef(basePath() / 'src) } + def resources = T{ PathRef(basePath() / 'resources) } def compiled = T{ compileScala(scalaVersion(), sources(), compileDepClasspath(), Task.ctx().dest) } |