From 302008684d51e49f0ce70516f283f15d41ea3831 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sun, 26 Nov 2017 07:15:08 -0800 Subject: bring back ScalaModule#run, bring back TaskModule now with a new defaultCommandName member --- .../src/main/scala/mill/scalaplugin/ScalaModule.scala | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'scalaplugin') diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala index 70bb1a35..a9c136d6 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala @@ -7,7 +7,7 @@ import java.util.Optional import ammonite.ops._ import coursier.{Cache, Fetch, MavenRepository, Repository, Resolution} import mill.define.Task -import mill.define.Task.Module +import mill.define.Task.{Module, TaskModule} import mill.eval.{Evaluator, PathRef} import mill.modules.Jvm.{createAssembly, createJar} import mill.util.OSet @@ -166,9 +166,10 @@ object ScalaModule{ ) } import ScalaModule._ -trait TestScalaModule extends ScalaModule { +trait TestScalaModule extends ScalaModule with TaskModule { + override def defaultCommandName() = "test" def testFramework: T[String] - def run(args: String*) = T.command{ + def test(args: String*) = T.command{ TestRunner( testFramework(), runDepClasspath().map(_.path) :+ compile().path, @@ -177,7 +178,8 @@ trait TestScalaModule extends ScalaModule { ) } } -trait ScalaModule extends Module{ outer => +trait ScalaModule extends Module with TaskModule{ outer => + def defaultCommandName() = "run" trait Tests extends TestScalaModule{ def scalaVersion = outer.scalaVersion() override def projectDeps = Seq(outer) @@ -276,6 +278,11 @@ trait ScalaModule extends Module{ outer => PathRef(dest) } + def run(mainClass: String) = T.command{ + import ammonite.ops._, ImplicitWd._ + %('java, "-cp", (runDepClasspath().map(_.path) :+ compile().path).mkString(":"), mainClass) + } + def console() = T.command{ import ammonite.ops._, ImplicitWd._ %('java, -- cgit v1.2.3