From 0cea8f67adc515e58b511283905caa3bce5e632a Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 20 Dec 2018 16:52:55 +0100 Subject: [PATCH] Added cmdline option -k/--keep-going See https://github.com/lihaoyi/mill/issues/477 --- main/src/MillMain.scala | 18 +++++++++++++++--- main/src/main/MainRunner.scala | 6 ++++-- main/src/main/MillServerMain.scala | 6 +++--- main/src/main/ReplApplyHandler.scala | 6 ++++-- main/src/main/RunScript.scala | 5 +++-- main/test/src/util/ScriptTestSuite.scala | 3 ++- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/main/src/MillMain.scala b/main/src/MillMain.scala index e953e65d74f..f1a7a9e7b19 100644 --- a/main/src/MillMain.scala +++ b/main/src/MillMain.scala @@ -73,8 +73,18 @@ object MillMain { } ) + var keepGoing = false + val keepGoingSignature = Arg[Config, Unit] ( + name = "keep-going", shortName = Some('k'), doc = "Continue build, even after build failures", + (c,v) => { + keepGoing = true + c + } + ) + val millArgSignature = - Cli.genericSignature.filter(a => !removed(a.name)) ++ Seq(interactiveSignature, disableTickerSignature, debugLogSignature) + Cli.genericSignature.filter(a => !removed(a.name)) ++ + Seq(interactiveSignature, disableTickerSignature, debugLogSignature, keepGoingSignature) Cli.groupArgs( args.toList, @@ -115,7 +125,8 @@ object MillMain { | repl.pprinter(), | build.millSelf.get, | build.millDiscover, - | $debugLog + | $debugLog, + | keepGoing = $keepGoing |) |repl.pprinter() = replApplyHandler.pprinter |import replApplyHandler.generatedEval._ @@ -131,7 +142,8 @@ object MillMain { stateCache, env, setIdle, - debugLog + debugLog, + keepGoing = keepGoing ) if (mill.main.client.Util.isJava9OrAbove) { diff --git a/main/src/main/MainRunner.scala b/main/src/main/MainRunner.scala index e50ed3708de..e08905a61ba 100644 --- a/main/src/main/MainRunner.scala +++ b/main/src/main/MainRunner.scala @@ -24,7 +24,8 @@ class MainRunner(val config: ammonite.main.Cli.Config, stateCache0: Option[Evaluator.State] = None, env : Map[String, String], setIdle: Boolean => Unit, - debugLog: Boolean) + debugLog: Boolean, + keepGoing: Boolean) extends ammonite.MainRunner( config, outprintStream, errPrintStream, stdIn, outprintStream, errPrintStream @@ -83,7 +84,8 @@ class MainRunner(val config: ammonite.main.Cli.Config, stdIn, debugEnabled = debugLog ), - env + env, + keepGoing = keepGoing ) result match{ diff --git a/main/src/main/MillServerMain.scala b/main/src/main/MillServerMain.scala index 26ca99e68cc..07d51254304 100644 --- a/main/src/main/MillServerMain.scala +++ b/main/src/main/MillServerMain.scala @@ -55,12 +55,12 @@ object MillServerMain extends mill.main.MillServerMain[Evaluator.State]{ MillMain.main0( args, stateCache, - mainInteractive, + mainInteractive = mainInteractive, DummyInputStream, stdout, stderr, env, - setIdle + setIdle = setIdle ) } } @@ -141,7 +141,7 @@ class Server[T](lockBase: String, stdout, stderr, env.asScala.toMap, - idle = _ + idle = _, ) sm.stateCache = newStateCache diff --git a/main/src/main/ReplApplyHandler.scala b/main/src/main/ReplApplyHandler.scala index 786a1409c2a..6f1e060d437 100644 --- a/main/src/main/ReplApplyHandler.scala +++ b/main/src/main/ReplApplyHandler.scala @@ -16,7 +16,8 @@ object ReplApplyHandler{ pprinter0: pprint.PPrinter, rootModule: mill.define.BaseModule, discover: Discover[_], - debugLog: Boolean) = { + debugLog: Boolean, + keepGoing: Boolean) = { new ReplApplyHandler( pprinter0, new Evaluator( @@ -33,7 +34,8 @@ object ReplApplyHandler{ System.err, System.in, debugEnabled = debugLog - ) + ), + failFast = !keepGoing ) ) } diff --git a/main/src/main/RunScript.scala b/main/src/main/RunScript.scala index b858c8b9e00..ea8e554f10a 100644 --- a/main/src/main/RunScript.scala +++ b/main/src/main/RunScript.scala @@ -29,7 +29,8 @@ object RunScript{ scriptArgs: Seq[String], stateCache: Option[Evaluator.State], log: Logger, - env : Map[String, String]) + env : Map[String, String], + keepGoing: Boolean) : (Res[(Evaluator, Seq[PathRef], Either[String, Seq[ujson.Value]])], Seq[(os.Path, Long)]) = { val (evalState, interpWatched) = stateCache match{ @@ -54,7 +55,7 @@ object RunScript{ val evalRes = for(s <- evalState) yield new Evaluator(home, wd / 'out, wd / 'out, s.rootModule, log, - s.classLoaderSig, s.workerCache, env) + s.classLoaderSig, s.workerCache, env, failFast = !keepGoing) val evaluated = for{ evaluator <- evalRes diff --git a/main/test/src/util/ScriptTestSuite.scala b/main/test/src/util/ScriptTestSuite.scala index f448aaafd60..92f57c4f333 100644 --- a/main/test/src/util/ScriptTestSuite.scala +++ b/main/test/src/util/ScriptTestSuite.scala @@ -15,10 +15,11 @@ abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{ val stdIn = new ByteArrayInputStream(Array()) val disableTicker = false val debugLog = false + val keepGoing = false lazy val runner = new mill.main.MainRunner( ammonite.main.Cli.Config(wd = wd), disableTicker, stdOutErr, stdOutErr, stdIn, None, Map.empty, - b => (), debugLog + b => (), debugLog, keepGoing = keepGoing ) def eval(s: String*) = { if (!fork) runner.runScript(workspacePath / buildPath , s.toList)