From b5edbee29402b228140701de9739d56ab1c7bcb4 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 29 Aug 2024 09:46:35 +0800 Subject: [PATCH 1/9] wip --- main/resolve/src/mill/resolve/Resolve.scala | 45 +++++++++++++-------- runner/src/mill/runner/MillCliConfig.scala | 13 ++++-- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/main/resolve/src/mill/resolve/Resolve.scala b/main/resolve/src/mill/resolve/Resolve.scala index adbbb0d85ab..ef20992d3aa 100644 --- a/main/resolve/src/mill/resolve/Resolve.scala +++ b/main/resolve/src/mill/resolve/Resolve.scala @@ -23,7 +23,8 @@ object Resolve { resolved: Seq[Resolved], args: Seq[String], selector: Segments, - nullCommandDefaults: Boolean + nullCommandDefaults: Boolean, + allowPositionalCommandArgs: Boolean ) = { Right(resolved.map(_.segments)) } @@ -37,7 +38,8 @@ object Resolve { resolved: Seq[Resolved], args: Seq[String], selector: Segments, - nullCommandDefaults: Boolean + nullCommandDefaults: Boolean, + allowPositionalCommandArgs: Boolean ) = { val taskList = resolved.map { case r: Resolved.Target => @@ -51,7 +53,7 @@ object Resolve { val instantiated = ResolveCore .instantiateModule0(baseModules, r.segments.init) .flatMap { case (mod, rootMod) => - instantiateCommand(rootMod, r, mod, args, nullCommandDefaults) + instantiateCommand(rootMod, r, mod, args, nullCommandDefaults, allowPositionalCommandArgs) } instantiated.map(Some(_)) @@ -75,7 +77,8 @@ object Resolve { r, value, args, - nullCommandDefaults + nullCommandDefaults, + allowPositionalCommandArgs ).map(Some(_)) } ) @@ -110,7 +113,8 @@ object Resolve { r: Resolved.Command, p: Module, args: Seq[String], - nullCommandDefaults: Boolean + nullCommandDefaults: Boolean, + allowPositionalCommandArgs: Boolean ) = { ResolveCore.catchWrapException { val invoked = invokeCommand0( @@ -118,7 +122,8 @@ object Resolve { r.segments.parts.last, rootModule.millDiscover.asInstanceOf[Discover[mill.define.Module]], args, - nullCommandDefaults + nullCommandDefaults, + allowPositionalCommandArgs ) invoked.head @@ -130,7 +135,8 @@ object Resolve { name: String, discover: Discover[mill.define.Module], rest: Seq[String], - nullCommandDefaults: Boolean + nullCommandDefaults: Boolean, + allowPositionalCommandArgs: Boolean ): Iterable[Either[String, Command[_]]] = for { (cls, (names, entryPoints)) <- discover.value if cls.isAssignableFrom(target.getClass) @@ -154,7 +160,7 @@ object Resolve { mainargs.TokenGrouping.groupArgs( rest, flattenedArgSigsWithDefaults, - allowPositional = true, + allowPositional = allowPositionalCommandArgs, allowRepeats = false, allowLeftover = ep.argSigs0.exists(_.reader.isLeftover), nameMapper = mainargs.Util.kebabCaseNameMapper @@ -195,35 +201,39 @@ trait Resolve[T] { resolved: Seq[Resolved], args: Seq[String], segments: Segments, - nullCommandDefaults: Boolean + nullCommandDefaults: Boolean, + allowPositionalCommandArgs: Boolean ): Either[String, Seq[T]] def resolve( rootModule: BaseModule, scriptArgs: Seq[String], - selectMode: SelectMode + selectMode: SelectMode, + allowPositionalCommandArgs: Boolean ): Either[String, List[T]] = { - resolve0(Seq(rootModule), scriptArgs, selectMode) + resolve0(Seq(rootModule), scriptArgs, selectMode, allowPositionalCommandArgs) } def resolve( rootModules: Seq[BaseModule], scriptArgs: Seq[String], - selectMode: SelectMode + selectMode: SelectMode, + allowPositionalCommandArgs: Boolean ): Either[String, List[T]] = { - resolve0(rootModules, scriptArgs, selectMode) + resolve0(rootModules, scriptArgs, selectMode, allowPositionalCommandArgs) } private[mill] def resolve0( baseModules: Seq[BaseModule], scriptArgs: Seq[String], - selectMode: SelectMode + selectMode: SelectMode, + allowPositionalCommandArgs: Boolean ): Either[String, List[T]] = { val nullCommandDefaults = selectMode == SelectMode.Multi val resolvedGroups = ParseArgs(scriptArgs, selectMode).flatMap { groups => val resolved = groups.map { case (selectors, args) => val selected = selectors.map { case (scopedSel, sel) => resolveRootModule(baseModules, scopedSel).map { rootModuleSels => - resolveNonEmptyAndHandle(args, rootModuleSels, sel, nullCommandDefaults) + resolveNonEmptyAndHandle(args, rootModuleSels, sel, nullCommandDefaults, allowPositionalCommandArgs) } } @@ -243,7 +253,8 @@ trait Resolve[T] { args: Seq[String], baseModules: BaseModuleTree, sel: Segments, - nullCommandDefaults: Boolean + nullCommandDefaults: Boolean, + allowPositionalCommandArgs: Boolean ): Either[String, Seq[T]] = { val rootResolved = ResolveCore.Resolved.Module(Segments(), baseModules.rootModule.getClass) val resolved = @@ -269,7 +280,7 @@ trait Resolve[T] { resolved .map(_.toSeq.sortBy(_.segments.render)) - .flatMap(handleResolved(baseModules, _, args, sel, nullCommandDefaults)) + .flatMap(handleResolved(baseModules, _, args, sel, nullCommandDefaults, allowPositionalCommandArgs)) } private[mill] def deduplicate(items: List[T]): List[T] = items diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index c81b0172135..5f57814ab83 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -122,7 +122,12 @@ class MillCliConfig private ( Level 0 is the normal project, level 1 the first meta-build, and so on. The last level is the built-in synthetic meta-build which Mill uses to bootstrap the project.""" ) - val metaLevel: Option[Int] + val metaLevel: Option[Int], + @arg( + doc = + """""" + ) + val allowPositionalCommandArgs: Flag, ) { override def toString: String = Seq( "home" -> home, @@ -145,7 +150,8 @@ class MillCliConfig private ( "leftoverArgs" -> leftoverArgs, "color" -> color, "disableCallgraphInvalidation" -> disableCallgraphInvalidation, - "metaLevel" -> metaLevel + "metaLevel" -> metaLevel, + "allowPositionalCommandArgs" -> allowPositionalCommandArgs, ).map(p => s"${p._1}=${p._2}").mkString(getClass().getSimpleName + "(", ",", ")") } @@ -202,7 +208,8 @@ object MillCliConfig { leftoverArgs = leftoverArgs, color = color, disableCallgraphInvalidation, - metaLevel = metaLevel + metaLevel = metaLevel, + allowPositionalCommandArgs = Flag() ) @deprecated("Bin-compat shim", "Mill after 0.11.0") From 5fd967c2f798fad986e87ecc8016d19b0f0f6c0c Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 29 Aug 2024 10:11:58 +0800 Subject: [PATCH 2/9] . --- example/depth/tasks/2-primary-tasks/build.sc | 58 ++++++++++++++++++- main/eval/src/mill/eval/Evaluator.scala | 2 +- main/eval/src/mill/eval/EvaluatorImpl.scala | 3 +- main/resolve/src/mill/resolve/Resolve.scala | 9 ++- main/src/mill/main/MainModule.scala | 2 +- main/src/mill/main/RunScript.scala | 4 +- .../src/mill/runner/MillBuildBootstrap.scala | 8 ++- runner/src/mill/runner/MillCliConfig.scala | 51 +++++++++++++++- runner/src/mill/runner/MillMain.scala | 3 +- testkit/src/mill/testkit/UnitTester.scala | 3 +- 10 files changed, 128 insertions(+), 15 deletions(-) diff --git a/example/depth/tasks/2-primary-tasks/build.sc b/example/depth/tasks/2-primary-tasks/build.sc index d7ddb698f14..1e5099c5ff4 100644 --- a/example/depth/tasks/2-primary-tasks/build.sc +++ b/example/depth/tasks/2-primary-tasks/build.sc @@ -52,6 +52,13 @@ def lineCount: T[Int] = T { // on other targets are defined using `foo()` to extract the value from them. // Apart from the `foo()` calls, the `T {...}` block contains arbitrary code that // does some work and returns a result. +// +// The `os.walk` and `os.read.lines` statements above are from the +// https://github.com/com-lihaoyi/os-lib[OS-Lib] library, which provides all common +// filesystem and subprocess operations for Mill builds. You can see the OS-Lib library +// documentation for more details: +// +// * https://github.com/com-lihaoyi/os-lib[OS-Lib Library Documentation] // If a target's inputs change but its output does not, e.g. someone changes a // comment within the source files that doesn't affect the classfiles, then @@ -102,7 +109,9 @@ Computing line count // The return-value of targets has to be JSON-serializable via // {upickle-github-url}[uPickle]. You can run targets directly from the command // line, or use `show` if you want to see the JSON content or pipe it to -// external tools. +// external tools. See the uPickle library documentation for more details: +// +// * {upickle-github-url}[uPickle Library Documentation] // ==== T.dest // @@ -257,11 +266,11 @@ def summarizeClassFileStats = T{ // === Commands -def run(args: String*) = T.command { +def run(mainClass: String, args: String*) = T.command { os.proc( "java", "-cp", s"${classFiles().path}:${resources().path}", - "foo.Foo", + mainClass, args ) .call(stdout = os.Inherit) @@ -285,6 +294,49 @@ def run(args: String*) = T.command { // re-evaluate every time even if none of their inputs have changed. // A command with no parameter is defined as `def myCommand() = T.command {...}`. // It is a compile error if `()` is missing. +// +// Targets can take command line params, parsed by the https://github.com/com-lihaoyi/mainargs[MainArgs] +// library. Thus the signature `def run(mainClass: String, args: String*)` takes +// params of the form `--main-class ... `: + +/** Usage + +> ./mill run --main-class foo.Foo hello world +Foo.value: 31337 +args: hello world +foo.txt resource: My Example Text + +*/ + +// Command line arguments can take most primitive types: `String`, `Int`, `Boolean`, etc., +// along with `Option[T]` representing optional values and `Seq[T]` representing repeatable values, +// and `mainargs.Flag` representing flags and `mainargs.Leftover[T]` representing any command line +// arguments not parsed earlier. Default values for command line arguments are also supported. +// See the mainargs documentation for more details: +// +// * [MainArgs Library Documentation](https://github.com/com-lihaoyi/mainargs[MainArgs]) +// +// By default, all command parameters need to be named, except for variadic parameters +// of type `T*` or `mainargs.Leftover[T]`. You can use the flag `--allow-positional-command-args` +// to allow arbitrary arguments to be passed positionally, as shown below: + +/** Usage + +> ./mill run foo.Foo hello world # this raises an error because `--main-class` is not given +error: Missing argument: --mainClass +Expected Signature: run + --mainClass + args ... +... + +> ./mill --allow-positional-command-args run foo.Foo hello world # this succeeds due to --allow-positional-command-args +Foo.value: 31337 +args: hello world +foo.txt resource: My Example Text + +*/ + + // // Like <<_targets>>, a command only evaluates after all its upstream // dependencies have completed, and will not begin to run if any upstream diff --git a/main/eval/src/mill/eval/Evaluator.scala b/main/eval/src/mill/eval/Evaluator.scala index 0ff9e0814a6..95d71744b28 100644 --- a/main/eval/src/mill/eval/Evaluator.scala +++ b/main/eval/src/mill/eval/Evaluator.scala @@ -33,7 +33,7 @@ trait Evaluator { def withBaseLogger(newBaseLogger: ColorLogger): Evaluator def withFailFast(newFailFast: Boolean): Evaluator - + def allowPositionalCommandArgs: Boolean def plan(goals: Agg[Task[_]]): (MultiBiMap[Terminal, Task[_]], Agg[Task[_]]) /** diff --git a/main/eval/src/mill/eval/EvaluatorImpl.scala b/main/eval/src/mill/eval/EvaluatorImpl.scala index 56ca20c862a..6c8fe56191d 100644 --- a/main/eval/src/mill/eval/EvaluatorImpl.scala +++ b/main/eval/src/mill/eval/EvaluatorImpl.scala @@ -27,7 +27,8 @@ private[mill] case class EvaluatorImpl( threadCount: Option[Int] = Some(1), scriptImportGraph: Map[os.Path, (Int, Seq[os.Path])] = Map.empty, methodCodeHashSignatures: Map[String, Int], - override val disableCallgraphInvalidation: Boolean + override val disableCallgraphInvalidation: Boolean, + allowPositionalCommandArgs: Boolean ) extends Evaluator with EvaluatorCore { import EvaluatorImpl._ diff --git a/main/resolve/src/mill/resolve/Resolve.scala b/main/resolve/src/mill/resolve/Resolve.scala index ef20992d3aa..26ce9e7da8a 100644 --- a/main/resolve/src/mill/resolve/Resolve.scala +++ b/main/resolve/src/mill/resolve/Resolve.scala @@ -209,7 +209,7 @@ trait Resolve[T] { rootModule: BaseModule, scriptArgs: Seq[String], selectMode: SelectMode, - allowPositionalCommandArgs: Boolean + allowPositionalCommandArgs: Boolean = false ): Either[String, List[T]] = { resolve0(Seq(rootModule), scriptArgs, selectMode, allowPositionalCommandArgs) } @@ -221,6 +221,13 @@ trait Resolve[T] { ): Either[String, List[T]] = { resolve0(rootModules, scriptArgs, selectMode, allowPositionalCommandArgs) } + def resolve( + rootModules: Seq[BaseModule], + scriptArgs: Seq[String], + selectMode: SelectMode, + ): Either[String, List[T]] = { + resolve0(rootModules, scriptArgs, selectMode, false) + } private[mill] def resolve0( baseModules: Seq[BaseModule], diff --git a/main/src/mill/main/MainModule.scala b/main/src/mill/main/MainModule.scala index e40a3e5df93..855d66d08a0 100644 --- a/main/src/mill/main/MainModule.scala +++ b/main/src/mill/main/MainModule.scala @@ -28,7 +28,7 @@ object MainModule { evaluator: Evaluator, targets: Seq[String], log: Logger, - watch0: Watchable => Unit + watch0: Watchable => Unit, )(f: Seq[(Any, Option[(RunScript.TaskName, ujson.Value)])] => ujson.Value) : Result[ujson.Value] = { diff --git a/main/src/mill/main/RunScript.scala b/main/src/mill/main/RunScript.scala index aa377e3386e..ac88444f253 100644 --- a/main/src/mill/main/RunScript.scala +++ b/main/src/mill/main/RunScript.scala @@ -15,13 +15,13 @@ object RunScript { def evaluateTasksNamed( evaluator: Evaluator, scriptArgs: Seq[String], - selectMode: SelectMode + selectMode: SelectMode, ): Either[ String, (Seq[Watchable], Either[String, Seq[(Any, Option[(TaskName, ujson.Value)])]]) ] = { val resolved = mill.eval.Evaluator.currentEvaluator.withValue(evaluator) { - Resolve.Tasks.resolve(evaluator.rootModules, scriptArgs, selectMode) + Resolve.Tasks.resolve(evaluator.rootModules, scriptArgs, selectMode, evaluator.allowPositionalCommandArgs) } for (targets <- resolved) yield evaluateNamed(evaluator, Agg.from(targets)) } diff --git a/runner/src/mill/runner/MillBuildBootstrap.scala b/runner/src/mill/runner/MillBuildBootstrap.scala index e7bd0f704fb..6e7369eac5e 100644 --- a/runner/src/mill/runner/MillBuildBootstrap.scala +++ b/runner/src/mill/runner/MillBuildBootstrap.scala @@ -39,7 +39,8 @@ class MillBuildBootstrap( logger: ColorLogger, disableCallgraphInvalidation: Boolean, needBuildSc: Boolean, - requestedMetaLevel: Option[Int] + requestedMetaLevel: Option[Int], + allowPositionalCommandArgs: Boolean ) { import MillBuildBootstrap._ @@ -362,7 +363,8 @@ class MillBuildBootstrap( threadCount = threadCount, scriptImportGraph = scriptImportGraph, methodCodeHashSignatures = methodCodeHashSignatures, - disableCallgraphInvalidation = disableCallgraphInvalidation + disableCallgraphInvalidation = disableCallgraphInvalidation, + allowPositionalCommandArgs = allowPositionalCommandArgs ) } @@ -403,7 +405,7 @@ object MillBuildBootstrap { def evaluateWithWatches( rootModules: Seq[BaseModule], evaluator: Evaluator, - targetsAndParams: Seq[String] + targetsAndParams: Seq[String], ): (Either[String, Seq[Any]], Seq[Watchable], Seq[Watchable]) = { rootModules.foreach(_.evalWatchedValues.clear()) val evalTaskResult = diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 5f57814ab83..0566fd9abe9 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -186,7 +186,56 @@ object MillCliConfig { leftoverArgs: Leftover[String] = Leftover(), color: Option[Boolean] = None, disableCallgraphInvalidation: Flag = Flag(), - metaLevel: Option[Int] = None + metaLevel: Option[Int] = None, + allowPositionalCommandArgs: Flag = Flag() + ): MillCliConfig = new MillCliConfig( + home = home, + repl = repl, + noServer = noServer, + bsp = bsp, + showVersion = showVersion, + ringBell = ringBell, + disableTicker = disableTicker, + enableTicker = enableTicker, + debugLog = debugLog, + keepGoing = keepGoing, + extraSystemProperties = extraSystemProperties, + threadCountRaw = threadCountRaw, + imports = imports, + interactive = interactive, + help = help, + watch = watch, + silent = silent, + leftoverArgs = leftoverArgs, + color = color, + disableCallgraphInvalidation, + metaLevel = metaLevel, + allowPositionalCommandArgs = allowPositionalCommandArgs + ) + @deprecated("Bin-compat shim", "Mill after 0.11.12") + def apply( + home: os.Path, + @deprecated("No longer supported.", "Mill 0.11.0-M8") + repl: Flag, + noServer: Flag, + bsp: Flag, + showVersion: Flag, + ringBell: Flag, + disableTicker: Flag, + enableTicker: Option[Boolean], + debugLog: Flag, + keepGoing: Flag, + extraSystemProperties: Map[String, String], + threadCountRaw: Option[Int], + imports: Seq[String], + interactive: Flag, + help: Flag, + watch: Flag, + silent: Flag, + leftoverArgs: Leftover[String], + color: Option[Boolean], + disableCallgraphInvalidation: Flag, + metaLevel: Option[Int] ): MillCliConfig = new MillCliConfig( home = home, repl = repl, diff --git a/runner/src/mill/runner/MillMain.scala b/runner/src/mill/runner/MillMain.scala index 96e137b3b10..e01c3aa96a4 100644 --- a/runner/src/mill/runner/MillMain.scala +++ b/runner/src/mill/runner/MillMain.scala @@ -231,7 +231,8 @@ object MillMain { logger = logger, disableCallgraphInvalidation = config.disableCallgraphInvalidation.value, needBuildSc = needBuildSc(config), - requestedMetaLevel = config.metaLevel + requestedMetaLevel = config.metaLevel, + config.allowPositionalCommandArgs.value ).evaluate() } ) diff --git a/testkit/src/mill/testkit/UnitTester.scala b/testkit/src/mill/testkit/UnitTester.scala index 52a633e4b0a..18b3c977d8e 100644 --- a/testkit/src/mill/testkit/UnitTester.scala +++ b/testkit/src/mill/testkit/UnitTester.scala @@ -99,7 +99,8 @@ class UnitTester( threadCount = threads, env = env, methodCodeHashSignatures = Map(), - disableCallgraphInvalidation = false + disableCallgraphInvalidation = false, + allowPositionalCommandArgs = false ) def apply(args: String*): Either[Result.Failing[_], UnitTester.Result[Seq[_]]] = { From 07f233fdd92e9b3ef6b8776760f2df4d28a66aeb Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 29 Aug 2024 10:19:29 +0800 Subject: [PATCH 3/9] . --- main/eval/src/mill/eval/Evaluator.scala | 2 +- main/eval/src/mill/eval/EvaluatorImpl.scala | 2 +- main/resolve/src/mill/resolve/Resolve.scala | 7 ++++ readme.adoc | 45 ++++++++++++--------- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/main/eval/src/mill/eval/Evaluator.scala b/main/eval/src/mill/eval/Evaluator.scala index 95d71744b28..c453f7ec7c8 100644 --- a/main/eval/src/mill/eval/Evaluator.scala +++ b/main/eval/src/mill/eval/Evaluator.scala @@ -33,7 +33,7 @@ trait Evaluator { def withBaseLogger(newBaseLogger: ColorLogger): Evaluator def withFailFast(newFailFast: Boolean): Evaluator - def allowPositionalCommandArgs: Boolean + def allowPositionalCommandArgs: Boolean = false def plan(goals: Agg[Task[_]]): (MultiBiMap[Terminal, Task[_]], Agg[Task[_]]) /** diff --git a/main/eval/src/mill/eval/EvaluatorImpl.scala b/main/eval/src/mill/eval/EvaluatorImpl.scala index 6c8fe56191d..0213465d3b7 100644 --- a/main/eval/src/mill/eval/EvaluatorImpl.scala +++ b/main/eval/src/mill/eval/EvaluatorImpl.scala @@ -28,7 +28,7 @@ private[mill] case class EvaluatorImpl( scriptImportGraph: Map[os.Path, (Int, Seq[os.Path])] = Map.empty, methodCodeHashSignatures: Map[String, Int], override val disableCallgraphInvalidation: Boolean, - allowPositionalCommandArgs: Boolean + override val allowPositionalCommandArgs: Boolean ) extends Evaluator with EvaluatorCore { import EvaluatorImpl._ diff --git a/main/resolve/src/mill/resolve/Resolve.scala b/main/resolve/src/mill/resolve/Resolve.scala index 26ce9e7da8a..d779037d0c5 100644 --- a/main/resolve/src/mill/resolve/Resolve.scala +++ b/main/resolve/src/mill/resolve/Resolve.scala @@ -213,6 +213,13 @@ trait Resolve[T] { ): Either[String, List[T]] = { resolve0(Seq(rootModule), scriptArgs, selectMode, allowPositionalCommandArgs) } + def resolve( + rootModule: BaseModule, + scriptArgs: Seq[String], + selectMode: SelectMode, + ): Either[String, List[T]] = { + resolve0(Seq(rootModule), scriptArgs, selectMode, false) + } def resolve( rootModules: Seq[BaseModule], scriptArgs: Seq[String], diff --git a/readme.adoc b/readme.adoc index 9b61bff9ab6..a2565118f3a 100644 --- a/readme.adoc +++ b/readme.adoc @@ -305,32 +305,39 @@ endif::[] [#main] branch === main -* Builds can now be modularized into per-folder definitions by defining -`module.sc` files in subfolders {link-pr}/3213[#3213] +* *Breaking Changes* + * Builds can now be modularized into per-folder definitions by defining + `module.sc` files in subfolders {link-pr}/3213[#3213] -* Turn on parallelism for task evaluation by default, except for commands -which always run serially at the end {link-pr}/3265[#3265] -* This can be disabled by passing `--jobs 1` + * Turn on parallelism for task evaluation by default, except for commands + which always run serially at the end {link-pr}/3265[#3265] + * This can be disabled by passing `--jobs 1` -* Overhaul the Mill client-server protocol to improve robustness -{link-pr}/3363[#3363] {link-pr}/3366[#3366] {link-pr}/3368[#3368] {link-pr}/3370[#3370] + * Overhaul the Mill client-server protocol to improve robustness + {link-pr}/3363[#3363] {link-pr}/3366[#3366] {link-pr}/3368[#3368] {link-pr}/3370[#3370] -* Mill uses empty sandbox folders as the working directory for running its own code and -{link-pr}/3367[#3367] and test suites {link-pr}/3347[#3347], to avoid accidental interference -between tasks and tests due to parallelism -* This can be disabled by adding `def testSandboxWorkingDir = false` in your test module + * Mill uses empty sandbox folders as the working directory for running its own code and + {link-pr}/3367[#3367] and test suites {link-pr}/3347[#3347], to avoid accidental interference + between tasks and tests due to parallelism + * This can be disabled by adding `def testSandboxWorkingDir = false` in your test module -* Mill now publishes unit, integration, and example test fixtures for writing plugins {link-pr}/3398[#3398] -for downstream plugin authors to use in testing their own Mill extensions + * Mill commands now require arguments to be passed named via `./mill mycommand --key value`, rather than + allowing just `./mill mycommand value`. {link-pr}/3431[#3431]. You can pass in + `--allow-positional-command-args` to fall back to the old behavior -* Bump default Sonatype Maven Central publishing timeouts to 10 minutes to avoid -timeouts due to slowness https://github.com/com-lihaoyi/mill/commit/b4c9386b0233fab53a312426715e226e4a7f6302 +* Other Changes + * Mill now publishes unit, integration, and example test fixtures for writing plugins {link-pr}/3398[#3398] + for downstream plugin authors to use in testing their own Mill extensions -* Importing Mill projects into IntelliJ via BSP now properly marks the `out/`, `.idea/`, and `.bsp/` folders -as excluded {link-pr}/3329[#3329] + * Bump default Sonatype Maven Central publishing timeouts to 10 minutes to avoid + timeouts due to slowness https://github.com/com-lihaoyi/mill/commit/b4c9386b0233fab53a312426715e226e4a7f6302 + + * Importing Mill projects into IntelliJ via BSP now properly marks the `out/`, `.idea/`, and `.bsp/` folders + as excluded {link-pr}/3329[#3329] + + * Optimizations to Mill evaluation logic to reduce fixed overhead of running Mill + on large projects {link-pr}/3388[#3388] -* Optimizations to Mill evaluation logic to reduce fixed overhead of running Mill -on large projects {link-pr}/3388[#3388] [#0-11-12] === 0.11.12 - 2024-08-20 From 4c3a7490ee9d526cf67172cb89d9856309ea119b Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 29 Aug 2024 10:20:08 +0800 Subject: [PATCH 4/9] . --- readme.adoc | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/readme.adoc b/readme.adoc index a2565118f3a..f34586a300d 100644 --- a/readme.adoc +++ b/readme.adoc @@ -306,37 +306,37 @@ endif::[] === main * *Breaking Changes* - * Builds can now be modularized into per-folder definitions by defining - `module.sc` files in subfolders {link-pr}/3213[#3213] + * Builds can now be modularized into per-folder definitions by defining + `module.sc` files in subfolders {link-pr}/3213[#3213] - * Turn on parallelism for task evaluation by default, except for commands - which always run serially at the end {link-pr}/3265[#3265] - * This can be disabled by passing `--jobs 1` + * Turn on parallelism for task evaluation by default, except for commands + which always run serially at the end {link-pr}/3265[#3265] + * This can be disabled by passing `--jobs 1` - * Overhaul the Mill client-server protocol to improve robustness - {link-pr}/3363[#3363] {link-pr}/3366[#3366] {link-pr}/3368[#3368] {link-pr}/3370[#3370] + * Overhaul the Mill client-server protocol to improve robustness + {link-pr}/3363[#3363] {link-pr}/3366[#3366] {link-pr}/3368[#3368] {link-pr}/3370[#3370] - * Mill uses empty sandbox folders as the working directory for running its own code and - {link-pr}/3367[#3367] and test suites {link-pr}/3347[#3347], to avoid accidental interference - between tasks and tests due to parallelism - * This can be disabled by adding `def testSandboxWorkingDir = false` in your test module + * Mill uses empty sandbox folders as the working directory for running its own code and + {link-pr}/3367[#3367] and test suites {link-pr}/3347[#3347], to avoid accidental interference + between tasks and tests due to parallelism + * This can be disabled by adding `def testSandboxWorkingDir = false` in your test module - * Mill commands now require arguments to be passed named via `./mill mycommand --key value`, rather than - allowing just `./mill mycommand value`. {link-pr}/3431[#3431]. You can pass in - `--allow-positional-command-args` to fall back to the old behavior + * Mill commands now require arguments to be passed named via `./mill mycommand --key value`, rather than + allowing just `./mill mycommand value`. {link-pr}/3431[#3431]. You can pass in + `--allow-positional-command-args` to fall back to the old behavior * Other Changes - * Mill now publishes unit, integration, and example test fixtures for writing plugins {link-pr}/3398[#3398] - for downstream plugin authors to use in testing their own Mill extensions - - * Bump default Sonatype Maven Central publishing timeouts to 10 minutes to avoid - timeouts due to slowness https://github.com/com-lihaoyi/mill/commit/b4c9386b0233fab53a312426715e226e4a7f6302 - - * Importing Mill projects into IntelliJ via BSP now properly marks the `out/`, `.idea/`, and `.bsp/` folders - as excluded {link-pr}/3329[#3329] - - * Optimizations to Mill evaluation logic to reduce fixed overhead of running Mill - on large projects {link-pr}/3388[#3388] + * Mill now publishes unit, integration, and example test fixtures for writing plugins {link-pr}/3398[#3398] + for downstream plugin authors to use in testing their own Mill extensions + + * Bump default Sonatype Maven Central publishing timeouts to 10 minutes to avoid + timeouts due to slowness https://github.com/com-lihaoyi/mill/commit/b4c9386b0233fab53a312426715e226e4a7f6302 + + * Importing Mill projects into IntelliJ via BSP now properly marks the `out/`, `.idea/`, and `.bsp/` folders + as excluded {link-pr}/3329[#3329] + + * Optimizations to Mill evaluation logic to reduce fixed overhead of running Mill + on large projects {link-pr}/3388[#3388] [#0-11-12] From a466610417969ebdbbd32f28854ad489d7ed1de9 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 29 Aug 2024 10:21:34 +0800 Subject: [PATCH 5/9] . --- readme.adoc | 56 +++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/readme.adoc b/readme.adoc index f34586a300d..005d8b9cfb2 100644 --- a/readme.adoc +++ b/readme.adoc @@ -306,37 +306,43 @@ endif::[] === main * *Breaking Changes* - * Builds can now be modularized into per-folder definitions by defining - `module.sc` files in subfolders {link-pr}/3213[#3213] +** Builds can now be modularized into per-folder definitions by defining +`module.sc` files in subfolders {link-pr}/3213[#3213] - * Turn on parallelism for task evaluation by default, except for commands - which always run serially at the end {link-pr}/3265[#3265] - * This can be disabled by passing `--jobs 1` +** Turn on parallelism for task evaluation by default, except for commands +which always run serially at the end {link-pr}/3265[#3265] - * Overhaul the Mill client-server protocol to improve robustness - {link-pr}/3363[#3363] {link-pr}/3366[#3366] {link-pr}/3368[#3368] {link-pr}/3370[#3370] +*** This can be disabled by passing `--jobs 1` - * Mill uses empty sandbox folders as the working directory for running its own code and - {link-pr}/3367[#3367] and test suites {link-pr}/3347[#3347], to avoid accidental interference - between tasks and tests due to parallelism - * This can be disabled by adding `def testSandboxWorkingDir = false` in your test module +** Mill uses empty sandbox folders as the working directory for running its own code and +{link-pr}/3367[#3367] and test suites {link-pr}/3347[#3347], to avoid accidental interference +between tasks and tests due to parallelism - * Mill commands now require arguments to be passed named via `./mill mycommand --key value`, rather than - allowing just `./mill mycommand value`. {link-pr}/3431[#3431]. You can pass in - `--allow-positional-command-args` to fall back to the old behavior +*** This can be disabled by adding `def testSandboxWorkingDir = false` in your test module + +** Mill commands now require arguments to be passed named via `./mill mycommand --key value`, rather than + allowing just `./mill mycommand value`. {link-pr}/3431[#3431]. + +*** You can pass in + `--allow-positional-command-args` to fall back to the old behavior * Other Changes - * Mill now publishes unit, integration, and example test fixtures for writing plugins {link-pr}/3398[#3398] - for downstream plugin authors to use in testing their own Mill extensions - - * Bump default Sonatype Maven Central publishing timeouts to 10 minutes to avoid - timeouts due to slowness https://github.com/com-lihaoyi/mill/commit/b4c9386b0233fab53a312426715e226e4a7f6302 - - * Importing Mill projects into IntelliJ via BSP now properly marks the `out/`, `.idea/`, and `.bsp/` folders - as excluded {link-pr}/3329[#3329] - - * Optimizations to Mill evaluation logic to reduce fixed overhead of running Mill - on large projects {link-pr}/3388[#3388] + +** Overhaul the Mill client-server protocol to improve robustness +{link-pr}/3363[#3363] {link-pr}/3366[#3366] {link-pr}/3368[#3368] {link-pr}/3370[#3370] + + +** Mill now publishes unit, integration, and example test fixtures for writing plugins {link-pr}/3398[#3398] +for downstream plugin authors to use in testing their own Mill extensions + +** Bump default Sonatype Maven Central publishing timeouts to 10 minutes to avoid +timeouts due to slowness https://github.com/com-lihaoyi/mill/commit/b4c9386b0233fab53a312426715e226e4a7f6302 + +** Importing Mill projects into IntelliJ via BSP now properly marks the `out/`, `.idea/`, and `.bsp/` folders +as excluded {link-pr}/3329[#3329] + +** Optimizations to Mill evaluation logic to reduce fixed overhead of running Mill +on large projects {link-pr}/3388[#3388] [#0-11-12] From ca88936fde9ee77feb4ee03f64d1cacc82010c6a Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 29 Aug 2024 10:22:35 +0800 Subject: [PATCH 6/9] . --- readme.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.adoc b/readme.adoc index 005d8b9cfb2..ad358394619 100644 --- a/readme.adoc +++ b/readme.adoc @@ -308,6 +308,9 @@ endif::[] * *Breaking Changes* ** Builds can now be modularized into per-folder definitions by defining `module.sc` files in subfolders {link-pr}/3213[#3213] +*** This change removes the ability to define targets and modules in arbitrary scripts that +you `import $file`. All targets and modules need to be moved to `module.sc` files in each +subfolder ** Turn on parallelism for task evaluation by default, except for commands which always run serially at the end {link-pr}/3265[#3265] From b2659b9f04448b19ebf102f1d541bc22d6f65272 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 29 Aug 2024 11:00:35 +0800 Subject: [PATCH 7/9] wip --- main/resolve/test/src/mill/main/ResolveTests.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/resolve/test/src/mill/main/ResolveTests.scala b/main/resolve/test/src/mill/main/ResolveTests.scala index 9bc60257681..e69bb041381 100644 --- a/main/resolve/test/src/mill/main/ResolveTests.scala +++ b/main/resolve/test/src/mill/main/ResolveTests.scala @@ -52,7 +52,8 @@ object ResolveTests extends TestSuite { Resolve.Tasks.resolve0( Seq(module), selectorStrings, - SelectMode.Separated + SelectMode.Separated, + false ) } @@ -60,7 +61,8 @@ object ResolveTests extends TestSuite { Resolve.Segments.resolve0( Seq(module), selectorStrings, - SelectMode.Separated + SelectMode.Separated, + false ).map(_.map(_.render)) } } From e0b6af884e062ced5c6d78cbc52b511fc0443c0f Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 29 Aug 2024 11:54:40 +0800 Subject: [PATCH 8/9] . --- main/src/mill/main/MainModule.scala | 5 ++++- main/test/src/mill/util/TestGraphs.scala | 15 ++++++++------- readme.adoc | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/main/src/mill/main/MainModule.scala b/main/src/mill/main/MainModule.scala index 855d66d08a0..c1cff2959ba 100644 --- a/main/src/mill/main/MainModule.scala +++ b/main/src/mill/main/MainModule.scala @@ -125,7 +125,10 @@ trait MainModule extends BaseModule0 { * If there are multiple dependency paths between `src` and `dest`, the path * chosen is arbitrary. */ - def path(evaluator: Evaluator, src: String, dest: String): Command[List[String]] = + + def path(evaluator: Evaluator, + @mainargs.arg(positional = true) src: String, + @mainargs.arg(positional = true) dest: String): Command[List[String]] = Target.command { val resolved = Resolve.Tasks.resolve( evaluator.rootModules, diff --git a/main/test/src/mill/util/TestGraphs.scala b/main/test/src/mill/util/TestGraphs.scala index a11c1c5d96f..993d53818f7 100644 --- a/main/test/src/mill/util/TestGraphs.scala +++ b/main/test/src/mill/util/TestGraphs.scala @@ -1,5 +1,6 @@ package mill.util import TestUtil.test +import mainargs.arg import mill.testkit.TestBaseModule import mill.define.{Command, Cross, Discover, DynamicModule, ModuleRef, TaskModule} import mill.{Module, T} @@ -132,21 +133,21 @@ class TestGraphs() { object moduleInitError extends TestBaseModule { def rootTarget = T { println("Running rootTarget"); "rootTarget Result" } - def rootCommand(s: String) = T.command { println(s"Running rootCommand $s") } + def rootCommand(@arg(positional = true) s: String) = T.command { println(s"Running rootCommand $s") } object foo extends Module { def fooTarget = T { println(s"Running fooTarget"); 123 } - def fooCommand(s: String) = T.command { println(s"Running fooCommand $s") } + def fooCommand(@arg(positional = true) s: String) = T.command { println(s"Running fooCommand $s") } throw new Exception("Foo Boom") } object bar extends Module { def barTarget = T { println(s"Running barTarget"); "barTarget Result" } - def barCommand(s: String) = T.command { println(s"Running barCommand $s") } + def barCommand(@arg(positional = true) s: String) = T.command { println(s"Running barCommand $s") } object qux extends Module { def quxTarget = T { println(s"Running quxTarget"); "quxTarget Result" } - def quxCommand(s: String) = T.command { println(s"Running quxCommand $s") } + def quxCommand(@arg(positional = true) s: String) = T.command { println(s"Running quxCommand $s") } throw new Exception("Qux Boom") } } @@ -158,7 +159,7 @@ class TestGraphs() { object foo extends Module { def fooTarget = T { println(s"Running fooTarget"); 123 } - def fooCommand(s: String) = T.command { println(s"Running fooCommand $s") } + def fooCommand(@arg(positional = true) s: String) = T.command { println(s"Running fooCommand $s") } throw new Exception("Foo Boom") } @@ -167,7 +168,7 @@ class TestGraphs() { println(s"Running barTarget") s"${foo.fooTarget()} barTarget Result" } - def barCommand(s: String) = T.command { + def barCommand(@arg(positional = true) s: String) = T.command { foo.fooCommand(s)() println(s"Running barCommand $s") } @@ -514,7 +515,7 @@ object TestGraphs { trait Cross2 extends mill.Cross.Module[String] with TaskModule { def platform = crossValue override def defaultCommandName(): String = "suffixCmd" - def suffixCmd(suffix: String = "default"): Command[String] = T.command { + def suffixCmd(@arg(positional = true) suffix: String = "default"): Command[String] = T.command { scalaVersion + "_" + platform + "_" + suffix } } diff --git a/readme.adoc b/readme.adoc index ad358394619..3d4850e8073 100644 --- a/readme.adoc +++ b/readme.adoc @@ -327,7 +327,8 @@ between tasks and tests due to parallelism allowing just `./mill mycommand value`. {link-pr}/3431[#3431]. *** You can pass in - `--allow-positional-command-args` to fall back to the old behavior + `--allow-positional-command-args` to fall back to the old behavior, or use `@mainargs.arg(positional = true)` + on individual parameters * Other Changes From 1d0121f6d00562a394abce36edcfdc49973703b5 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 29 Aug 2024 12:29:35 +0800 Subject: [PATCH 9/9] . --- .../depth/tasks/3-anonymous-tasks/build.sc | 4 +-- .../test/src/ModuleInitErrorTests.scala | 8 ++--- main/resolve/src/mill/resolve/Resolve.scala | 30 +++++++++++++++---- main/src/mill/main/MainModule.scala | 10 ++++--- main/src/mill/main/RunScript.scala | 9 ++++-- main/test/src/mill/util/TestGraphs.scala | 22 +++++++++----- .../src/mill/runner/MillBuildBootstrap.scala | 2 +- runner/src/mill/runner/MillCliConfig.scala | 4 +-- 8 files changed, 61 insertions(+), 28 deletions(-) diff --git a/example/depth/tasks/3-anonymous-tasks/build.sc b/example/depth/tasks/3-anonymous-tasks/build.sc index 24f3678fd68..9cef6f900cd 100644 --- a/example/depth/tasks/3-anonymous-tasks/build.sc +++ b/example/depth/tasks/3-anonymous-tasks/build.sc @@ -32,10 +32,10 @@ def printFileData(fileName: String) = T.command { > ./mill show helloFileData "Hello" -> ./mill printFileData hello.txt +> ./mill printFileData --file-name hello.txt Hello -> ./mill printFileData world.txt +> ./mill printFileData --file-name world.txt World! */ diff --git a/integration/failure/module-init-error/test/src/ModuleInitErrorTests.scala b/integration/failure/module-init-error/test/src/ModuleInitErrorTests.scala index 890988f6ead..a0609b6856d 100644 --- a/integration/failure/module-init-error/test/src/ModuleInitErrorTests.scala +++ b/integration/failure/module-init-error/test/src/ModuleInitErrorTests.scala @@ -53,7 +53,7 @@ object ModuleInitErrorTests extends IntegrationTestSuite { test("rootCommand") { // If we specify a target in the root module, we are not // affected by the sub-modules failing to initialize - val res = eval(("rootCommand", "hello")) + val res = eval(("rootCommand", "-s", "hello")) assert(res.isSuccess == true) assert(res.out.contains("""Running rootCommand hello""")) } @@ -66,7 +66,7 @@ object ModuleInitErrorTests extends IntegrationTestSuite { assert(fansi.Str(res.err).plainText.linesIterator.size < 20) } test("fooCommand") { - val res = eval(("foo.fooCommand", "hello")) + val res = eval(("foo.fooCommand", "-s", "hello")) assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Foo Boom""")) assert(fansi.Str(res.err).plainText.linesIterator.size < 20) @@ -77,7 +77,7 @@ object ModuleInitErrorTests extends IntegrationTestSuite { assert(res.out.contains("""Running barTarget""")) } test("barCommand") { - val res = eval(("bar.barCommand", "hello")) + val res = eval(("bar.barCommand", "-s", "hello")) assert(res.isSuccess == true) assert(res.out.contains("""Running barCommand hello""")) } @@ -88,7 +88,7 @@ object ModuleInitErrorTests extends IntegrationTestSuite { assert(fansi.Str(res.err).plainText.linesIterator.size < 20) } test("quxCommand") { - val res = eval(("bar.qux.quxCommand", "hello")) + val res = eval(("bar.qux.quxCommand", "-s", "hello")) assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Qux Boom""")) assert(fansi.Str(res.err).plainText.linesIterator.size < 20) diff --git a/main/resolve/src/mill/resolve/Resolve.scala b/main/resolve/src/mill/resolve/Resolve.scala index d779037d0c5..ef077aba593 100644 --- a/main/resolve/src/mill/resolve/Resolve.scala +++ b/main/resolve/src/mill/resolve/Resolve.scala @@ -53,7 +53,14 @@ object Resolve { val instantiated = ResolveCore .instantiateModule0(baseModules, r.segments.init) .flatMap { case (mod, rootMod) => - instantiateCommand(rootMod, r, mod, args, nullCommandDefaults, allowPositionalCommandArgs) + instantiateCommand( + rootMod, + r, + mod, + args, + nullCommandDefaults, + allowPositionalCommandArgs + ) } instantiated.map(Some(_)) @@ -216,7 +223,7 @@ trait Resolve[T] { def resolve( rootModule: BaseModule, scriptArgs: Seq[String], - selectMode: SelectMode, + selectMode: SelectMode ): Either[String, List[T]] = { resolve0(Seq(rootModule), scriptArgs, selectMode, false) } @@ -231,7 +238,7 @@ trait Resolve[T] { def resolve( rootModules: Seq[BaseModule], scriptArgs: Seq[String], - selectMode: SelectMode, + selectMode: SelectMode ): Either[String, List[T]] = { resolve0(rootModules, scriptArgs, selectMode, false) } @@ -247,7 +254,13 @@ trait Resolve[T] { val resolved = groups.map { case (selectors, args) => val selected = selectors.map { case (scopedSel, sel) => resolveRootModule(baseModules, scopedSel).map { rootModuleSels => - resolveNonEmptyAndHandle(args, rootModuleSels, sel, nullCommandDefaults, allowPositionalCommandArgs) + resolveNonEmptyAndHandle( + args, + rootModuleSels, + sel, + nullCommandDefaults, + allowPositionalCommandArgs + ) } } @@ -294,7 +307,14 @@ trait Resolve[T] { resolved .map(_.toSeq.sortBy(_.segments.render)) - .flatMap(handleResolved(baseModules, _, args, sel, nullCommandDefaults, allowPositionalCommandArgs)) + .flatMap(handleResolved( + baseModules, + _, + args, + sel, + nullCommandDefaults, + allowPositionalCommandArgs + )) } private[mill] def deduplicate(items: List[T]): List[T] = items diff --git a/main/src/mill/main/MainModule.scala b/main/src/mill/main/MainModule.scala index c1cff2959ba..cbe2bc37137 100644 --- a/main/src/mill/main/MainModule.scala +++ b/main/src/mill/main/MainModule.scala @@ -28,7 +28,7 @@ object MainModule { evaluator: Evaluator, targets: Seq[String], log: Logger, - watch0: Watchable => Unit, + watch0: Watchable => Unit )(f: Seq[(Any, Option[(RunScript.TaskName, ujson.Value)])] => ujson.Value) : Result[ujson.Value] = { @@ -126,9 +126,11 @@ trait MainModule extends BaseModule0 { * chosen is arbitrary. */ - def path(evaluator: Evaluator, - @mainargs.arg(positional = true) src: String, - @mainargs.arg(positional = true) dest: String): Command[List[String]] = + def path( + evaluator: Evaluator, + @mainargs.arg(positional = true) src: String, + @mainargs.arg(positional = true) dest: String + ): Command[List[String]] = Target.command { val resolved = Resolve.Tasks.resolve( evaluator.rootModules, diff --git a/main/src/mill/main/RunScript.scala b/main/src/mill/main/RunScript.scala index ac88444f253..e38a76d5441 100644 --- a/main/src/mill/main/RunScript.scala +++ b/main/src/mill/main/RunScript.scala @@ -15,13 +15,18 @@ object RunScript { def evaluateTasksNamed( evaluator: Evaluator, scriptArgs: Seq[String], - selectMode: SelectMode, + selectMode: SelectMode ): Either[ String, (Seq[Watchable], Either[String, Seq[(Any, Option[(TaskName, ujson.Value)])]]) ] = { val resolved = mill.eval.Evaluator.currentEvaluator.withValue(evaluator) { - Resolve.Tasks.resolve(evaluator.rootModules, scriptArgs, selectMode, evaluator.allowPositionalCommandArgs) + Resolve.Tasks.resolve( + evaluator.rootModules, + scriptArgs, + selectMode, + evaluator.allowPositionalCommandArgs + ) } for (targets <- resolved) yield evaluateNamed(evaluator, Agg.from(targets)) } diff --git a/main/test/src/mill/util/TestGraphs.scala b/main/test/src/mill/util/TestGraphs.scala index 993d53818f7..3be987128a6 100644 --- a/main/test/src/mill/util/TestGraphs.scala +++ b/main/test/src/mill/util/TestGraphs.scala @@ -133,21 +133,25 @@ class TestGraphs() { object moduleInitError extends TestBaseModule { def rootTarget = T { println("Running rootTarget"); "rootTarget Result" } - def rootCommand(@arg(positional = true) s: String) = T.command { println(s"Running rootCommand $s") } + def rootCommand(@arg(positional = true) s: String) = + T.command { println(s"Running rootCommand $s") } object foo extends Module { def fooTarget = T { println(s"Running fooTarget"); 123 } - def fooCommand(@arg(positional = true) s: String) = T.command { println(s"Running fooCommand $s") } + def fooCommand(@arg(positional = true) s: String) = + T.command { println(s"Running fooCommand $s") } throw new Exception("Foo Boom") } object bar extends Module { def barTarget = T { println(s"Running barTarget"); "barTarget Result" } - def barCommand(@arg(positional = true) s: String) = T.command { println(s"Running barCommand $s") } + def barCommand(@arg(positional = true) s: String) = + T.command { println(s"Running barCommand $s") } object qux extends Module { def quxTarget = T { println(s"Running quxTarget"); "quxTarget Result" } - def quxCommand(@arg(positional = true) s: String) = T.command { println(s"Running quxCommand $s") } + def quxCommand(@arg(positional = true) s: String) = + T.command { println(s"Running quxCommand $s") } throw new Exception("Qux Boom") } } @@ -159,7 +163,8 @@ class TestGraphs() { object foo extends Module { def fooTarget = T { println(s"Running fooTarget"); 123 } - def fooCommand(@arg(positional = true) s: String) = T.command { println(s"Running fooCommand $s") } + def fooCommand(@arg(positional = true) s: String) = + T.command { println(s"Running fooCommand $s") } throw new Exception("Foo Boom") } @@ -515,9 +520,10 @@ object TestGraphs { trait Cross2 extends mill.Cross.Module[String] with TaskModule { def platform = crossValue override def defaultCommandName(): String = "suffixCmd" - def suffixCmd(@arg(positional = true) suffix: String = "default"): Command[String] = T.command { - scalaVersion + "_" + platform + "_" + suffix - } + def suffixCmd(@arg(positional = true) suffix: String = "default"): Command[String] = + T.command { + scalaVersion + "_" + platform + "_" + suffix + } } } diff --git a/runner/src/mill/runner/MillBuildBootstrap.scala b/runner/src/mill/runner/MillBuildBootstrap.scala index 6e7369eac5e..f259f9fad81 100644 --- a/runner/src/mill/runner/MillBuildBootstrap.scala +++ b/runner/src/mill/runner/MillBuildBootstrap.scala @@ -405,7 +405,7 @@ object MillBuildBootstrap { def evaluateWithWatches( rootModules: Seq[BaseModule], evaluator: Evaluator, - targetsAndParams: Seq[String], + targetsAndParams: Seq[String] ): (Either[String, Seq[Any]], Seq[Watchable], Seq[Watchable]) = { rootModules.foreach(_.evalWatchedValues.clear()) val evalTaskResult = diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 0566fd9abe9..99cefc1d712 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -127,7 +127,7 @@ class MillCliConfig private ( doc = """""" ) - val allowPositionalCommandArgs: Flag, + val allowPositionalCommandArgs: Flag ) { override def toString: String = Seq( "home" -> home, @@ -151,7 +151,7 @@ class MillCliConfig private ( "color" -> color, "disableCallgraphInvalidation" -> disableCallgraphInvalidation, "metaLevel" -> metaLevel, - "allowPositionalCommandArgs" -> allowPositionalCommandArgs, + "allowPositionalCommandArgs" -> allowPositionalCommandArgs ).map(p => s"${p._1}=${p._2}").mkString(getClass().getSimpleName + "(", ",", ")") }