diff options
-rw-r--r-- | main/src/mill/Main.scala | 12 | ||||
-rw-r--r-- | main/src/mill/main/MainRunner.scala | 2 | ||||
-rw-r--r-- | main/src/mill/main/RunScript.scala | 23 | ||||
-rw-r--r-- | main/test/src/mill/util/ScriptTestSuite.scala | 2 |
4 files changed, 15 insertions, 24 deletions
diff --git a/main/src/mill/Main.scala b/main/src/mill/Main.scala index c8e445c9..d2d2f66f 100644 --- a/main/src/mill/Main.scala +++ b/main/src/mill/Main.scala @@ -2,14 +2,14 @@ package mill import java.io.{InputStream, OutputStream, PrintStream} -import ammonite.main.Cli + import ammonite.main.Cli.{formatBlock, genericSignature, replSignature} import ammonite.ops._ import ammonite.util.Util import mill.eval.Evaluator -import mill.main.MainRunner object Main { + def main(args: Array[String]): Unit = { val (result, _) = main0( args, @@ -21,6 +21,7 @@ object Main { ) System.exit(if(result) 0 else 1) } + def main0(args: Array[String], stateCache: Option[Evaluator.State], mainInteractive: Boolean, @@ -77,13 +78,12 @@ object Main { stateCache ) - if (repl){ runner.printInfo("Loading...") - (runner.watchLoop(isRepl = true, printing = false, _.run()), stateCache) + (runner.watchLoop(isRepl = true, printing = false, _.run()), runner.stateCache) } else { - (runner.runScript(pwd / "build.sc", leftoverArgs), stateCache) + (runner.runScript(pwd / "build.sc", leftoverArgs), runner.stateCache) } } } -}
\ No newline at end of file +} diff --git a/main/src/mill/main/MainRunner.scala b/main/src/mill/main/MainRunner.scala index 8ec018c6..8f546ced 100644 --- a/main/src/mill/main/MainRunner.scala +++ b/main/src/mill/main/MainRunner.scala @@ -68,6 +68,7 @@ class MainRunner(val config: ammonite.main.Cli.Config, val (eval, evaluationWatches, res) = data val watched = interpWatched ++ evaluationWatches + stateCache = Some(Evaluator.State(eval.rootModule, eval.classLoaderSig, eval.workerCache, watched)) (Res(res), watched) @@ -83,6 +84,7 @@ class MainRunner(val config: ammonite.main.Cli.Config, } } + override def initMain(isRepl: Boolean) = { super.initMain(isRepl).copy( scriptCodeWrapper = CustomCodeWrapper, diff --git a/main/src/mill/main/RunScript.scala b/main/src/mill/main/RunScript.scala index 9a6700fd..ff0f5b62 100644 --- a/main/src/mill/main/RunScript.scala +++ b/main/src/mill/main/RunScript.scala @@ -32,14 +32,14 @@ object RunScript{ : (Res[(Evaluator[Any], Seq[(Path, Long)], Either[String, Seq[Js.Value]])], Seq[(Path, Long)]) = { val (evalState, interpWatched) = stateCache match{ - case Some(s) if watchedSigUnchanged(s.classLoaderSig) => Res.Success(s) -> s.watched + case Some(s) if watchedSigUnchanged(s.watched) => Res.Success(s) -> s.watched case _ => instantiateInterpreter match{ case Left((res, watched)) => (res, watched) case Right(interp) => interp.watch(path) val eval = - for((rootModule, discover) <- evaluateMapping(wd, path, interp)) + for(rootModule <- evaluateRootModule(wd, path, interp)) yield Evaluator.State( rootModule, rootModule.getClass.getClassLoader.asInstanceOf[SpecialClassLoader].classpathSignature, @@ -78,9 +78,9 @@ object RunScript{ sig.forall{case (p, l) => Interpreter.pathSignature(p) == l} } - def evaluateMapping(wd: Path, - path: Path, - interp: ammonite.interp.Interpreter): Res[(mill.define.BaseModule, Discover[Any])] = { + def evaluateRootModule(wd: Path, + path: Path, + interp: ammonite.interp.Interpreter): Res[mill.define.BaseModule] = { val (pkg, wrapper) = Util.pathToPackageWrapper(Seq(), path relativeTo wd) @@ -118,19 +118,8 @@ object RunScript{ } catch { case e: Throwable => Res.Exception(e, "") } - discover <- try { - Util.withContextClassloader(interp.evalClassloader) { - Res.Success( - buildCls.getMethod("millDiscover") - .invoke(module) - .asInstanceOf[Discover[Any]] - ) - } - } catch { - case e: Throwable => Res.Exception(e, "") - } // _ <- Res(consistencyCheck(mapping)) - } yield (module, discover) + } yield module } def resolveTasks[T, R: ClassTag](resolver: mill.main.Resolve[R], diff --git a/main/test/src/mill/util/ScriptTestSuite.scala b/main/test/src/mill/util/ScriptTestSuite.scala index 8958b464..1f89ab8d 100644 --- a/main/test/src/mill/util/ScriptTestSuite.scala +++ b/main/test/src/mill/util/ScriptTestSuite.scala @@ -15,7 +15,7 @@ abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{ val stdIn = new ByteArrayInputStream(Array()) lazy val runner = new mill.main.MainRunner( ammonite.main.Cli.Config(wd = workspacePath), - stdOutErr, stdOutErr, stdIn + stdOutErr, stdOutErr, stdIn, () => false ) def eval(s: String*) = { if (!fork) runner.runScript(workspacePath / "build.sc", s.toList) |