diff options
-rwxr-xr-x | build.sc | 21 | ||||
-rw-r--r-- | core/src/main/scala/mill/Main.scala | 5 | ||||
-rw-r--r-- | readme.md | 2 | ||||
-rw-r--r-- | scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala | 13 | ||||
-rw-r--r-- | scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala | 17 |
5 files changed, 34 insertions, 24 deletions
@@ -35,25 +35,16 @@ object Core extends ScalaModule { PathRef(dest) } } -} -object CoreTests extends ScalaModule { - def scalaVersion = "2.12.4" - override def projectDeps = Seq(Core) - def basePath = pwd / 'scalaplugin - override def sources = pwd/'core/'src/'test/'scala - override def ivyDeps = Seq( - Dep("com.lihaoyi", "utest", "0.6.0") - ) - def test() = T.command{ - TestRunner.apply( - "mill.UTestFramework", - runDepClasspath().map(_.path) :+ compile().path, - Seq(compile().path) - ) + object tests extends this.Tests{ + def basePath = pwd / 'core + override def ivyDeps = Seq(Dep("com.lihaoyi", "utest", "0.6.0")) + override def sources = pwd/'core/'src/'test/'scala + def testFramework = "mill.UTestFramework" } } + object ScalaPlugin extends ScalaModule { def scalaVersion = "2.12.4" override def projectDeps = Seq(Core) diff --git a/core/src/main/scala/mill/Main.scala b/core/src/main/scala/mill/Main.scala index ef4a78a6..6f1d3bd3 100644 --- a/core/src/main/scala/mill/Main.scala +++ b/core/src/main/scala/mill/Main.scala @@ -225,7 +225,10 @@ class Main(config: Main.Config){ } else { val interp = ammonite.Main( predefFile = Some(pwd / "build.sc") - ).instantiateInterpreter().right.get + ).instantiateInterpreter()match{ + case Left(x) => println(x); ??? + case Right(x) => x + } interp.initializePredef() val syntheticPath = pwd / 'out / "run.sc" @@ -23,7 +23,7 @@ core unit tests e.g.: ```bash ./scalaplugin/target/mill run Core.compile -./scalaplugin/target/mill run CoreTests.test +./scalaplugin/target/mill run Core.tests.run ./scalaplugin/target/mill run ScalaPlugin.assembly ``` diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala b/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala index 02dbbc91..7bfe14e1 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala @@ -24,12 +24,15 @@ object GenIdea { val workspacePath = pwd / 'out val evaluator = new Evaluator(workspacePath, mapping, _ => ()) - val modules = Mirror.traverse(obj, discovered.mirror){ (h, p) => - h.node(obj, p.map{case Mirror.Segment.Cross(vs) => vs case _ => Nil}.toList) match { - case m: ScalaModule => Seq(p -> m) - case _ => Nil + val modules = Mirror + .traverse(obj, discovered.mirror){ (h, p) => + h.node(obj, p.map{case Mirror.Segment.Cross(vs) => vs case _ => Nil}.toList) match { + case m: ScalaModule => Seq(p -> m) + case _ => Nil + } } - } + .map{case (p, v) => (p.reverse, v)} + val resolved = for((path, mod) <- modules) yield { val Seq(resolvedCp: Seq[PathRef], resolvedSrcs: Seq[PathRef]) = evaluator.evaluate(OSet(mod.externalCompileDepClasspath, mod.externalCompileDepSources)) diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala index e1b3c130..d2c37782 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala @@ -161,8 +161,21 @@ object ScalaModule{ ) } import ScalaModule._ - -trait ScalaModule extends Module{ +trait TestScalaModule extends ScalaModule{ + def testFramework: T[String] + def run() = T.command{ + TestRunner( + testFramework(), + runDepClasspath().map(_.path) :+ compile().path, + Seq(compile().path) + ) + } +} +trait ScalaModule extends Module{ outer => + trait Tests extends TestScalaModule{ + def scalaVersion = outer.scalaVersion() + override def projectDeps = Seq(outer) + } def scalaVersion: T[String] def scalaBinaryVersion = T{ scalaVersion().split('.').dropRight(1).mkString(".") } |