diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-25 08:01:24 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-25 08:01:24 -0800 |
commit | c3f2dc919cff83f105a60061456090f0c907f0b1 (patch) | |
tree | 83cfa7e36649eddfe2e2e797f3baaaa782507a49 /core/src/main | |
parent | ac62721c10cc61d3913cf71c3ef2e9e0680ddeb9 (diff) | |
download | mill-c3f2dc919cff83f105a60061456090f0c907f0b1.tar.gz mill-c3f2dc919cff83f105a60061456090f0c907f0b1.tar.bz2 mill-c3f2dc919cff83f105a60061456090f0c907f0b1.zip |
First pass at simplifying test suite definition & running
Added a `TaskModule` subclass of `Module`, which delegates to a `self` task that you can run directly from bash
Fixed `GenIdea` to fix reversing of module path in generating module name
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/scala/mill/Main.scala | 13 | ||||
-rw-r--r-- | core/src/main/scala/mill/define/Task.scala | 4 |
2 files changed, 16 insertions, 1 deletions
diff --git a/core/src/main/scala/mill/Main.scala b/core/src/main/scala/mill/Main.scala index 6f1d3bd3..7b48c9c7 100644 --- a/core/src/main/scala/mill/Main.scala +++ b/core/src/main/scala/mill/Main.scala @@ -10,6 +10,7 @@ import mill.eval.{Evaluator, Result} import mill.util.OSet import ammonite.main.Scripts.pathScoptRead import ammonite.repl.Repl +import mill.define.Task.TaskModule object Main { @@ -52,13 +53,23 @@ object Main { case Left(last) :: Nil => def target: Option[Task[Any]] = hierarchy.targets.find(_.label == last).map(_.run(hierarchy.node(obj, crossSelectors))) + + def targetModule: Seq[Task[Any]] = for{ + (label, child) <- hierarchy.children + if label == last + node <- child.node(obj, crossSelectors) match{ + case x: TaskModule => Some(x) + case _ => None + } + } yield node.self + def command: Option[Task[Any]] = hierarchy.commands.find(_.name == last).flatMap( _.invoke(hierarchy.node(obj, crossSelectors), ammonite.main.Scripts.groupArgs(rest.toList)) match{ case Router.Result.Success(v) => Some(v) case _ => None } ) - target orElse command + target orElse command orElse targetModule.headOption case head :: tail => head match{ case Left(singleLabel) => diff --git a/core/src/main/scala/mill/define/Task.scala b/core/src/main/scala/mill/define/Task.scala index 5aa97eff..91eb3793 100644 --- a/core/src/main/scala/mill/define/Task.scala +++ b/core/src/main/scala/mill/define/Task.scala @@ -145,6 +145,10 @@ object Task { trait Module extends mill.define.Cacher[Target]{ def wrapCached[T](t: Target[T], enclosing: String): Target[T] = t } + trait TaskModule extends Module { + def self(): Task[_] + } + class Task0[T](t: T) extends Task[T]{ lazy val t0 = t val inputs = Nil |