From c47520fff31942d2f86f87436386b23fd7ec81de Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 11:18:10 +0800 Subject: [PATCH 01/19] . --- .../ROOT/partials/Intro_to_Mill_Footer.adoc | 4 - main/eval/src/mill/eval/EvaluatorImpl.scala | 2 +- main/eval/src/mill/eval/GroupEvaluator.scala | 105 +++++++-------- .../src/mill/runner/MillBuildBootstrap.scala | 4 +- runner/src/mill/runner/MillCliConfig.scala | 122 ++++++++++-------- runner/src/mill/runner/MillMain.scala | 11 +- testkit/src/mill/testkit/UnitTester.scala | 2 +- 7 files changed, 129 insertions(+), 121 deletions(-) diff --git a/docs/modules/ROOT/partials/Intro_to_Mill_Footer.adoc b/docs/modules/ROOT/partials/Intro_to_Mill_Footer.adoc index dc851ab5795..254b3f05f6e 100644 --- a/docs/modules/ROOT/partials/Intro_to_Mill_Footer.adoc +++ b/docs/modules/ROOT/partials/Intro_to_Mill_Footer.adoc @@ -73,10 +73,6 @@ usage: mill [options] [[target [target-options]] [+ [target ...]]] in both REPL and scripts mode if the console is interactive, and disabled otherwise. -d --debug Show debug output on STDOUT - --disable-callgraph-invalidation Disable the fine-grained callgraph-based target invalidation in - response to code changes, and instead fall back to the previous - coarse-grained implementation relying on the script `import - $file` graph --disable-ticker Disable ticker log (e.g. short-lived prints of stages and progress bars). --enable-ticker Enable ticker log (e.g. short-lived prints of stages and diff --git a/main/eval/src/mill/eval/EvaluatorImpl.scala b/main/eval/src/mill/eval/EvaluatorImpl.scala index 6049929ea99..508bf7b1f5c 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( 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 disableCallgraph: Boolean, override val allowPositionalCommandArgs: Boolean, val systemExit: Int => Nothing ) extends Evaluator with EvaluatorCore { diff --git a/main/eval/src/mill/eval/GroupEvaluator.scala b/main/eval/src/mill/eval/GroupEvaluator.scala index fafd4eb6ba3..7d1529801ea 100644 --- a/main/eval/src/mill/eval/GroupEvaluator.scala +++ b/main/eval/src/mill/eval/GroupEvaluator.scala @@ -33,7 +33,7 @@ private[mill] trait GroupEvaluator { def threadCount: Option[Int] def scriptImportGraph: Map[os.Path, (Int, Seq[os.Path])] def methodCodeHashSignatures: Map[String, Int] - def disableCallgraphInvalidation: Boolean + def disableCallgraph: Boolean def systemExit: Int => Nothing lazy val constructorHashSignatures: Map[String, Seq[(String, Int)]] = methodCodeHashSignatures @@ -64,59 +64,60 @@ private[mill] trait GroupEvaluator { val sideHashes = MurmurHash3.orderedHash(group.iterator.map(_.sideHash)) - val scriptsHash = group - .iterator - .collect { - case namedTask: NamedTask[_] => - val encodedTaskName = encode(namedTask.ctx.segment.pathSegments.head) - val methodOpt = for { - parentCls <- classToTransitiveClasses(namedTask.ctx.enclosingCls).iterator - m <- allTransitiveClassMethods(parentCls).get(encodedTaskName) - } yield m - - val methodClass = methodOpt - .nextOption() - .getOrElse(throw new MillException( - s"Could not detect the parent class of target ${namedTask}. " + - s"Please report this at ${BuildInfo.millReportNewIssueUrl} . " + - s"As a workaround, you can run Mill with `--disable-callgraph-invalidation` option." - )) - .getDeclaringClass.getName - - val name = namedTask.ctx.segment.pathSegments.last - val expectedName = methodClass + "#" + name + "()mill.define.Target" - - // We not only need to look up the code hash of the Target method being called, - // but also the code hash of the constructors required to instantiate the Module - // that the Target is being called on. This can be done by walking up the nested - // modules and looking at their constructors (they're `object`s and should each - // have only one) - val allEnclosingModules = Vector.unfold(namedTask.ctx) { - case null => None - case ctx => - ctx.enclosingModule match { - case null => None - case m: mill.define.Module => Some((m, m.millOuterCtx)) - case unknown => - throw new MillException(s"Unknown ctx of target ${namedTask}: $unknown") - } - } + val scriptsHash = + if (disableCallgraph) 0 + else group + .iterator + .collect { + case namedTask: NamedTask[_] => + val encodedTaskName = encode(namedTask.ctx.segment.pathSegments.head) + val methodOpt = for { + parentCls <- classToTransitiveClasses(namedTask.ctx.enclosingCls).iterator + m <- allTransitiveClassMethods(parentCls).get(encodedTaskName) + } yield m + + val methodClass = methodOpt + .nextOption() + .getOrElse(throw new MillException( + s"Could not detect the parent class of target ${namedTask}. " + + s"Please report this at ${BuildInfo.millReportNewIssueUrl} . " + )) + .getDeclaringClass.getName + + val name = namedTask.ctx.segment.pathSegments.last + val expectedName = methodClass + "#" + name + "()mill.define.Target" + + // We not only need to look up the code hash of the Target method being called, + // but also the code hash of the constructors required to instantiate the Module + // that the Target is being called on. This can be done by walking up the nested + // modules and looking at their constructors (they're `object`s and should each + // have only one) + val allEnclosingModules = Vector.unfold(namedTask.ctx) { + case null => None + case ctx => + ctx.enclosingModule match { + case null => None + case m: mill.define.Module => Some((m, m.millOuterCtx)) + case unknown => + throw new MillException(s"Unknown ctx of target ${namedTask}: $unknown") + } + } - val constructorHashes = allEnclosingModules - .map(m => - constructorHashSignatures.get(m.getClass.getName) match { - case Some(Seq((singleMethod, hash))) => hash - case Some(multiple) => throw new MillException( - s"Multiple constructors found for module $m: ${multiple.mkString(",")}" - ) - case None => 0 - } - ) + val constructorHashes = allEnclosingModules + .map(m => + constructorHashSignatures.get(m.getClass.getName) match { + case Some(Seq((singleMethod, hash))) => hash + case Some(multiple) => throw new MillException( + s"Multiple constructors found for module $m: ${multiple.mkString(",")}" + ) + case None => 0 + } + ) - methodCodeHashSignatures.get(expectedName) ++ constructorHashes - } - .flatten - .sum + methodCodeHashSignatures.get(expectedName) ++ constructorHashes + } + .flatten + .sum val inputsHash = externalInputsHash + sideHashes + classLoaderSigHash + scriptsHash diff --git a/runner/src/mill/runner/MillBuildBootstrap.scala b/runner/src/mill/runner/MillBuildBootstrap.scala index fa1db8f2a84..30e7827e057 100644 --- a/runner/src/mill/runner/MillBuildBootstrap.scala +++ b/runner/src/mill/runner/MillBuildBootstrap.scala @@ -38,7 +38,7 @@ class MillBuildBootstrap( targetsAndParams: Seq[String], prevRunnerState: RunnerState, logger: ColorLogger, - disableCallgraphInvalidation: Boolean, + disableCallgraph: Boolean, needBuildSc: Boolean, requestedMetaLevel: Option[Int], allowPositionalCommandArgs: Boolean, @@ -351,7 +351,7 @@ class MillBuildBootstrap( failFast = !keepGoing, threadCount = threadCount, methodCodeHashSignatures = methodCodeHashSignatures, - disableCallgraphInvalidation = disableCallgraphInvalidation, + disableCallgraph = disableCallgraph, allowPositionalCommandArgs = allowPositionalCommandArgs, systemExit = systemExit ) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 7d7a8c39f02..a3dd3247d26 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -6,8 +6,7 @@ class MillCliConfig private ( @arg( short = 'h', doc = - """(internal) The home directory of internally used Ammonite script engine; - where it looks for config and caches.""" + """(internal) The home directory where Mill looks for config and caches.""" ) val home: os.Path, // We need to keep it, otherwise, a given --repl would be silently parsed as target and result in misleading error messages. @@ -19,9 +18,7 @@ class MillCliConfig private ( ) val repl: Flag, @arg( - doc = """Run Mill in single-process mode. - In this mode, no Mill server will be started or used. - Must be the first argument.""" + doc = """Run Mill in single-process mode without a background server. Must be the first argument.""" ) val noServer: Flag, @arg(doc = """Enable BSP server mode.""") @@ -34,17 +31,12 @@ class MillCliConfig private ( doc = """Ring the bell once if the run completes successfully, twice if it fails.""" ) val ringBell: Flag, - @arg( - doc = - """Disable ticker log (e.g. short-lived prints of stages and progress bars).""" - ) - val disableTicker: Flag, @arg( doc = """Enable ticker log (e.g. short-lived prints of stages and progress bars).""" ) - val enableTicker: Option[Boolean], + val ticker: Option[Boolean], @arg(name = "debug", short = 'd', doc = "Show debug output on STDOUT") val debugLog: Flag, @arg( @@ -62,8 +54,11 @@ class MillCliConfig private ( name = "jobs", short = 'j', doc = - """Allow processing N targets in parallel. - Use 1 to disable parallel and 0 to use as much threads as available processors.""" + """The number of parallel threads. It can be an integer e.g. `5` + meaning 5 threads, an expression e.g. `0.5C` meaning + half as many threads as available cores, or `C-2` + meaning 2 threads less than the number of cores. `1` disables + parallelism and `0` (the default) uses 1 thread per core.""" ) val threadCountRaw: Option[Int], @arg( @@ -95,37 +90,31 @@ class MillCliConfig private ( @arg( name = "target", doc = - """The name or a pattern of the target(s) you want to build, - followed by any parameters you wish to pass to those targets. - To specify multiple target names or patterns, use the `+` separator.""" + """The name or a pattern of the target(s) you want to build.""" ) val leftoverArgs: Leftover[String], @arg( doc = - """Enable or disable colored output; by default colors are enabled - in both REPL and scripts mode if the console is interactive, and disabled - otherwise.""" + """Enable or disable colored output; by default colors are enabled in both REPL and scripts mode if + the console is interactive, and disabled otherwise.""" ) val color: Option[Boolean], @arg( - doc = - """Disable the fine-grained callgraph-based target invalidation in response to - code changes, and instead fall back to the previous coarse-grained implementation - relying on the script `import $file` graph""" + name = "disable-callgraph", + doc = """ + Disables fine-grained invalidation of tasks based on analyzing code changes. If passed, you will + need to manually run `clean` yourself after build changes. + """ ) - val disableCallgraphInvalidation: Flag, + val disableCallgraph: Flag, @arg( doc = - """Experimental: Select a meta-build level to run the given targets. - 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.""" + """Select a meta-build level to run the given targets. Level 0 is the normal project, + level 1 the first meta-build, and so on. The last level is a synthetic meta-build used for bootstrapping""" ) val metaLevel: Option[Int], - @arg( - doc = - """""" - ) - val allowPositionalCommandArgs: Flag + @arg(doc = "Allows command args to be passed positionally without `--arg` by default") + val allowPositional: Flag ) { override def toString: String = Seq( "home" -> home, @@ -134,8 +123,7 @@ class MillCliConfig private ( "bsp" -> bsp, "showVersion" -> showVersion, "ringBell" -> ringBell, - "disableTicker" -> disableTicker, - "enableTicker" -> enableTicker, + "ticker" -> ticker, "debugLog" -> debugLog, "keepGoing" -> keepGoing, "extraSystemProperties" -> extraSystemProperties, @@ -147,9 +135,9 @@ class MillCliConfig private ( "silent" -> silent, "leftoverArgs" -> leftoverArgs, "color" -> color, - "disableCallgraphInvalidation" -> disableCallgraphInvalidation, + "disableCallgraph" -> disableCallgraph, "metaLevel" -> metaLevel, - "allowPositionalCommandArgs" -> allowPositionalCommandArgs + "allowPositional" -> allowPositional ).map(p => s"${p._1}=${p._2}").mkString(getClass().getSimpleName + "(", ",", ")") } @@ -170,8 +158,7 @@ object MillCliConfig { bsp: Flag = Flag(), showVersion: Flag = Flag(), ringBell: Flag = Flag(), - disableTicker: Flag = Flag(), - enableTicker: Option[Boolean] = None, + ticker: Option[Boolean] = None, debugLog: Flag = Flag(), keepGoing: Flag = Flag(), extraSystemProperties: Map[String, String] = Map(), @@ -183,9 +170,9 @@ object MillCliConfig { silent: Flag = Flag(), leftoverArgs: Leftover[String] = Leftover(), color: Option[Boolean] = None, - disableCallgraphInvalidation: Flag = Flag(), + disableCallgraph: Flag = Flag(), metaLevel: Option[Int] = None, - allowPositionalCommandArgs: Flag = Flag() + allowPositional: Flag = Flag() ): MillCliConfig = new MillCliConfig( home = home, repl = repl, @@ -193,8 +180,7 @@ object MillCliConfig { bsp = bsp, showVersion = showVersion, ringBell = ringBell, - disableTicker = disableTicker, - enableTicker = enableTicker, + ticker = ticker, debugLog = debugLog, keepGoing = keepGoing, extraSystemProperties = extraSystemProperties, @@ -206,9 +192,9 @@ object MillCliConfig { silent = silent, leftoverArgs = leftoverArgs, color = color, - disableCallgraphInvalidation, + disableCallgraph, metaLevel = metaLevel, - allowPositionalCommandArgs = allowPositionalCommandArgs + allowPositional = allowPositional ) @deprecated("Bin-compat shim", "Mill after 0.11.12") def apply( @@ -219,8 +205,7 @@ object MillCliConfig { bsp: Flag, showVersion: Flag, ringBell: Flag, - disableTicker: Flag, - enableTicker: Option[Boolean], + ticker: Option[Boolean], debugLog: Flag, keepGoing: Flag, extraSystemProperties: Map[String, String], @@ -241,8 +226,7 @@ object MillCliConfig { bsp = bsp, showVersion = showVersion, ringBell = ringBell, - disableTicker = disableTicker, - enableTicker = enableTicker, + ticker = ticker, debugLog = debugLog, keepGoing = keepGoing, extraSystemProperties = extraSystemProperties, @@ -256,7 +240,7 @@ object MillCliConfig { color = color, disableCallgraphInvalidation, metaLevel = metaLevel, - allowPositionalCommandArgs = Flag() + allowPositional = Flag() ) @deprecated("Bin-compat shim", "Mill after 0.11.0") @@ -268,8 +252,7 @@ object MillCliConfig { bsp: Flag, showVersion: Flag, ringBell: Flag, - disableTicker: Flag, - enableTicker: Option[Boolean], + ticker: Option[Boolean], debugLog: Flag, keepGoing: Flag, extraSystemProperties: Map[String, String], @@ -290,8 +273,7 @@ object MillCliConfig { bsp, showVersion, ringBell, - disableTicker, - enableTicker, + ticker, debugLog, keepGoing, extraSystemProperties, @@ -313,15 +295,43 @@ import mainargs.ParserForClass // see https://github.com/com-lihaoyi/mill/issues/2315 object MillCliConfigParser { val customName: String = s"Mill Build Tool, version ${mill.main.BuildInfo.millVersion}" - val customDoc = "usage: mill [options] [[target [target-options]] [+ [target ...]]]" + val customDoc = """ +usage: mill [options] [[target [target-options]] [+ [target ...]]] + +target cheat sheet: + +./mill resolve _ # see all top-level tasks and modules +./mill resolve __.compile # see all `compile` tasks in any module (recursively) + +./mill foo.bar.compile # compile the module `foo.bar` + +./mill foo.run --arg 1 # run the main method of the module `foo` and pass in `--arg 1` +./mill -i foo.console # run the Scala console for the module `foo` (if it is a ScalaModule) + +./mill foo.__.test # run tests in module within `foo` (recursively) +./mill foo.test arg1 arg2 arg3 # run tests in the `foo` module passing in test arguments `arg1 arg2 arg3` +./mill foo.test + bar.test # run tests in the `foo` module and `bar` module +./mill '{foo,bar,qux}.test' # run tests in the `foo` module, `bar` module, and `qux` module + +./mill foo.assembly # generate an executable assembly of the module `foo` + +./mill show foo.assembly # print the output path of the assembly of module `foo` +./mill inspect foo.assembly # show docs and metadata for the `assembly` task on module `foo` + +./mill clean foo.assembly # delete the output of `foo.assembly` to force re-evaluation +./mill clean # delete the output of the entire build to force force re-evaluation + +./mill path foo.run foo.sources # print the dependency chain showing how `foo.run` depends on `foo.sources` +./mill visualize __.compile # show how the various `compile` tasks in each module depend on one another + +options:""" import mill.api.JsonFormatters._ private[this] lazy val parser: ParserForClass[MillCliConfig] = mainargs.ParserForClass[MillCliConfig] - lazy val usageText: String = - parser.helpText(customName = customName, customDoc = customDoc) + lazy val usageText: String = customName + "\n" + customDoc + parser.helpText(customName="", totalWidth=120) def parse(args: Array[String]): Either[String, MillCliConfig] = { parser.constructEither( diff --git a/runner/src/mill/runner/MillMain.scala b/runner/src/mill/runner/MillMain.scala index 56733cbc571..9ce566835cd 100644 --- a/runner/src/mill/runner/MillMain.scala +++ b/runner/src/mill/runner/MillMain.scala @@ -160,7 +160,7 @@ object MillMain { streams, config, mainInteractive, - enableTicker = if (config.disableTicker.value) Some(false) else config.enableTicker, + enableTicker = config.ticker, printLoggerState ) if (!config.silent.value) { @@ -176,8 +176,9 @@ object MillMain { (false, stateCache) } else if (!bspMode && config.leftoverArgs.value.isEmpty) { - logger.error("A target must be provided.") - (false, stateCache) + println(MillCliConfigParser.usageText) + + (true, stateCache) } else { val userSpecifiedProperties = @@ -232,10 +233,10 @@ object MillMain { targetsAndParams = targetsAndParams, prevRunnerState = prevState.getOrElse(stateCache), logger = logger, - disableCallgraphInvalidation = config.disableCallgraphInvalidation.value, + disableCallgraph = config.disableCallgraph.value, needBuildSc = needBuildSc(config), requestedMetaLevel = config.metaLevel, - config.allowPositionalCommandArgs.value, + config.allowPositional.value, systemExit = systemExit ).evaluate() } diff --git a/testkit/src/mill/testkit/UnitTester.scala b/testkit/src/mill/testkit/UnitTester.scala index 379479d9d47..22f48de1f43 100644 --- a/testkit/src/mill/testkit/UnitTester.scala +++ b/testkit/src/mill/testkit/UnitTester.scala @@ -99,7 +99,7 @@ class UnitTester( threadCount = threads, env = env, methodCodeHashSignatures = Map(), - disableCallgraphInvalidation = false, + disableCallgraph = false, allowPositionalCommandArgs = false, systemExit = i => ??? ) From 0cfa004f0095719376d25b2f308dcc1fc0bdf69d Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 11:31:09 +0800 Subject: [PATCH 02/19] . --- runner/src/mill/runner/MillCliConfig.scala | 165 ++------------------- 1 file changed, 10 insertions(+), 155 deletions(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index a3dd3247d26..bb1ffb1efb8 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -2,7 +2,7 @@ package mill.runner import mainargs.{Flag, Leftover, arg} -class MillCliConfig private ( +case class MillCliConfig ( @arg( short = 'h', doc = @@ -18,7 +18,7 @@ class MillCliConfig private ( ) val repl: Flag, @arg( - doc = """Run Mill in single-process mode without a background server. Must be the first argument.""" + doc = """Run without a background server. Must be the first argument.""" ) val noServer: Flag, @arg(doc = """Enable BSP server mode.""") @@ -70,7 +70,7 @@ class MillCliConfig private ( short = 'i', doc = """Run Mill in interactive mode, suitable for opening REPLs and taking user input. - This implies --no-server and no mill server will be used. Must be the first argument.""" + This implies --no-server. Must be the first argument.""" ) val interactive: Flag, @arg(doc = "Print this help message and exit.") @@ -102,7 +102,7 @@ class MillCliConfig private ( @arg( name = "disable-callgraph", doc = """ - Disables fine-grained invalidation of tasks based on analyzing code changes. If passed, you will + Disables fine-grained invalidation of tasks based on analyzing code changes. If passed, you need to manually run `clean` yourself after build changes. """ ) @@ -141,153 +141,6 @@ class MillCliConfig private ( ).map(p => s"${p._1}=${p._2}").mkString(getClass().getSimpleName + "(", ",", ")") } -object MillCliConfig { - /* - * mainargs requires us to keep this apply method in sync with the private ctr of the class. - * mainargs is designed to work with case classes, - * but case classes can't be evolved in a binary compatible fashion. - * mainargs parses the class ctr for its internal model, - * but uses the companion's apply to actually create an instance of the config class, - * hence we need both in sync. - */ - def apply( - home: os.Path = mill.api.Ctx.defaultHome, - @deprecated("No longer supported.", "Mill 0.11.0-M8") - repl: Flag = Flag(), - noServer: Flag = Flag(), - bsp: Flag = Flag(), - showVersion: Flag = Flag(), - ringBell: Flag = Flag(), - ticker: Option[Boolean] = None, - debugLog: Flag = Flag(), - keepGoing: Flag = Flag(), - extraSystemProperties: Map[String, String] = Map(), - threadCountRaw: Option[Int] = None, - imports: Seq[String] = Seq(), - interactive: Flag = Flag(), - help: Flag = Flag(), - watch: Flag = Flag(), - silent: Flag = Flag(), - leftoverArgs: Leftover[String] = Leftover(), - color: Option[Boolean] = None, - disableCallgraph: Flag = Flag(), - metaLevel: Option[Int] = None, - allowPositional: Flag = Flag() - ): MillCliConfig = new MillCliConfig( - home = home, - repl = repl, - noServer = noServer, - bsp = bsp, - showVersion = showVersion, - ringBell = ringBell, - ticker = ticker, - debugLog = debugLog, - keepGoing = keepGoing, - extraSystemProperties = extraSystemProperties, - threadCountRaw = threadCountRaw, - imports = imports, - interactive = interactive, - help = help, - watch = watch, - silent = silent, - leftoverArgs = leftoverArgs, - color = color, - disableCallgraph, - metaLevel = metaLevel, - allowPositional = allowPositional - ) - @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, - ticker: 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, - noServer = noServer, - bsp = bsp, - showVersion = showVersion, - ringBell = ringBell, - ticker = ticker, - 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, - allowPositional = Flag() - ) - - @deprecated("Bin-compat shim", "Mill after 0.11.0") - private[runner] def apply( - home: os.Path, - @deprecated("No longer supported.", "Mill 0.11.0-M8") - repl: Flag, - noServer: Flag, - bsp: Flag, - showVersion: Flag, - ringBell: Flag, - ticker: Option[Boolean], - debugLog: Flag, - keepGoing: Flag, - extraSystemProperties: Map[String, String], - threadCountRaw: Option[Int], - imports: Seq[String], - interactive: Flag, - help: Flag, - watch: Flag, - silent: Flag, - noDefaultPredef: Flag, - leftoverArgs: Leftover[String], - color: Option[Boolean], - predefFile: Option[os.Path] - ): MillCliConfig = apply( - home, - repl, - noServer, - bsp, - showVersion, - ringBell, - ticker, - debugLog, - keepGoing, - extraSystemProperties, - threadCountRaw, - imports, - interactive, - help, - watch, - silent, - leftoverArgs, - color - ) -} - import mainargs.ParserForClass // We want this in a separate source file, but to avoid stale --help output due @@ -299,7 +152,6 @@ object MillCliConfigParser { usage: mill [options] [[target [target-options]] [+ [target ...]]] target cheat sheet: - ./mill resolve _ # see all top-level tasks and modules ./mill resolve __.compile # see all `compile` tasks in any module (recursively) @@ -314,7 +166,6 @@ target cheat sheet: ./mill '{foo,bar,qux}.test' # run tests in the `foo` module, `bar` module, and `qux` module ./mill foo.assembly # generate an executable assembly of the module `foo` - ./mill show foo.assembly # print the output path of the assembly of module `foo` ./mill inspect foo.assembly # show docs and metadata for the `assembly` task on module `foo` @@ -324,14 +175,18 @@ target cheat sheet: ./mill path foo.run foo.sources # print the dependency chain showing how `foo.run` depends on `foo.sources` ./mill visualize __.compile # show how the various `compile` tasks in each module depend on one another -options:""" +options: +""" import mill.api.JsonFormatters._ private[this] lazy val parser: ParserForClass[MillCliConfig] = mainargs.ParserForClass[MillCliConfig] - lazy val usageText: String = customName + "\n" + customDoc + parser.helpText(customName="", totalWidth=120) + lazy val usageText: String = + customName + + customDoc + + parser.helpText(customName="", totalWidth=100).stripPrefix("\n").stripSuffix("\n") def parse(args: Array[String]): Either[String, MillCliConfig] = { parser.constructEither( From ae91c33ecfadfd31f265bdef7424332c4eb4bd61 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 11:45:23 +0800 Subject: [PATCH 03/19] . --- runner/src/mill/runner/MillCliConfig.scala | 56 ++++++++++------------ 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index bb1ffb1efb8..5c4eecc5650 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -2,13 +2,13 @@ package mill.runner import mainargs.{Flag, Leftover, arg} -case class MillCliConfig ( +case class MillCliConfig( @arg( short = 'h', doc = """(internal) The home directory where Mill looks for config and caches.""" ) - val home: os.Path, + home: os.Path = mill.api.Ctx.defaultHome, // We need to keep it, otherwise, a given --repl would be silently parsed as target and result in misleading error messages. // Instead we fail programmatically when this flag is set. @deprecated("No longer supported.", "Mill 0.11.0-M8") @@ -16,40 +16,40 @@ case class MillCliConfig ( hidden = true, doc = """This flag is no longer supported.""" ) - val repl: Flag, + repl: Flag = Flag(), @arg( doc = """Run without a background server. Must be the first argument.""" ) - val noServer: Flag, + noServer: Flag = Flag(), @arg(doc = """Enable BSP server mode.""") - val bsp: Flag, + bsp: Flag, @arg(name = "version", short = 'v', doc = "Show mill version information and exit.") - val showVersion: Flag, + showVersion: Flag = Flag(), @arg( name = "bell", short = 'b', doc = """Ring the bell once if the run completes successfully, twice if it fails.""" ) - val ringBell: Flag, + ringBell: Flag = Flag(), @arg( doc = """Enable ticker log (e.g. short-lived prints of stages and progress bars).""" ) - val ticker: Option[Boolean], + ticker: Option[Boolean] = None, @arg(name = "debug", short = 'd', doc = "Show debug output on STDOUT") - val debugLog: Flag, + debugLog: Flag = Flag(), @arg( short = 'k', doc = """Continue build, even after build failures.""" ) - val keepGoing: Flag, + keepGoing: Flag = Flag(), @arg( name = "define", short = 'D', doc = """Define (or overwrite) a system property.""" ) - val extraSystemProperties: Map[String, String], + extraSystemProperties: Map[String, String] = Map(), @arg( name = "jobs", short = 'j', @@ -60,45 +60,40 @@ case class MillCliConfig ( meaning 2 threads less than the number of cores. `1` disables parallelism and `0` (the default) uses 1 thread per core.""" ) - val threadCountRaw: Option[Int], + threadCountRaw: Option[Int] = None, @arg( name = "import", doc = """Additional ivy dependencies to load into mill, e.g. plugins.""" ) - val imports: Seq[String], + imports: Seq[String] = Nil, @arg( short = 'i', doc = """Run Mill in interactive mode, suitable for opening REPLs and taking user input. This implies --no-server. Must be the first argument.""" ) - val interactive: Flag, + interactive: Flag = Flag(), @arg(doc = "Print this help message and exit.") - val help: Flag, + help: Flag, @arg( short = 'w', doc = """Watch and re-run your scripts when they change.""" ) - val watch: Flag, + watch: Flag = Flag(), @arg( short = 's', doc = """Make ivy logs during script import resolution go silent instead of printing; though failures will still throw exception.""" ) - val silent: Flag, + silent: Flag = Flag(), @arg( name = "target", - doc = - """The name or a pattern of the target(s) you want to build.""" - ) - val leftoverArgs: Leftover[String], - @arg( - doc = - """Enable or disable colored output; by default colors are enabled in both REPL and scripts mode if - the console is interactive, and disabled otherwise.""" + doc = """The name or a pattern of the target(s) you want to build.""" ) - val color: Option[Boolean], + leftoverArgs: Leftover[String] = Leftover(), + @arg(doc = """Toggle colored output; by default enabled only if the console is interactive""") + color: Option[Boolean] = None, @arg( name = "disable-callgraph", doc = """ @@ -106,15 +101,15 @@ case class MillCliConfig ( need to manually run `clean` yourself after build changes. """ ) - val disableCallgraph: Flag, + disableCallgraph: Flag = Flag(), @arg( doc = """Select a meta-build level to run the given targets. Level 0 is the normal project, level 1 the first meta-build, and so on. The last level is a synthetic meta-build used for bootstrapping""" ) - val metaLevel: Option[Int], + metaLevel: Option[Int] = None, @arg(doc = "Allows command args to be passed positionally without `--arg` by default") - val allowPositional: Flag + allowPositional: Flag = Flag() ) { override def toString: String = Seq( "home" -> home, @@ -186,7 +181,8 @@ options: lazy val usageText: String = customName + customDoc + - parser.helpText(customName="", totalWidth=100).stripPrefix("\n").stripSuffix("\n") + parser.helpText(customName = "", totalWidth = 100).stripPrefix("\n") + + "\nPlease see the documentation at https://mill-build.org for more details" def parse(args: Array[String]): Either[String, MillCliConfig] = { parser.constructEither( From a527c9f7b197b95bc6d61d7c7a6fcc61b97712dc Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 11:46:02 +0800 Subject: [PATCH 04/19] . --- runner/src/mill/runner/MillCliConfig.scala | 29 ++-------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 5c4eecc5650..7b185fbece0 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -83,8 +83,7 @@ case class MillCliConfig( @arg( short = 's', doc = - """Make ivy logs during script import resolution go silent instead of printing; - though failures will still throw exception.""" + """Make ivy logs during script import resolution go silent instead of printing""" ) silent: Flag = Flag(), @arg( @@ -110,31 +109,7 @@ case class MillCliConfig( metaLevel: Option[Int] = None, @arg(doc = "Allows command args to be passed positionally without `--arg` by default") allowPositional: Flag = Flag() -) { - override def toString: String = Seq( - "home" -> home, - "repl" -> repl, - "noServer" -> noServer, - "bsp" -> bsp, - "showVersion" -> showVersion, - "ringBell" -> ringBell, - "ticker" -> ticker, - "debugLog" -> debugLog, - "keepGoing" -> keepGoing, - "extraSystemProperties" -> extraSystemProperties, - "threadCountRaw" -> threadCountRaw, - "imports" -> imports, - "interactive" -> interactive, - "help" -> help, - "watch" -> watch, - "silent" -> silent, - "leftoverArgs" -> leftoverArgs, - "color" -> color, - "disableCallgraph" -> disableCallgraph, - "metaLevel" -> metaLevel, - "allowPositional" -> allowPositional - ).map(p => s"${p._1}=${p._2}").mkString(getClass().getSimpleName + "(", ",", ")") -} +) import mainargs.ParserForClass From fd71ea23e904a4c71551aa76181b0079899757ac Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 11:51:45 +0800 Subject: [PATCH 05/19] . --- .config/mill-version | 2 +- runner/src/mill/runner/MillCliConfig.scala | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.config/mill-version b/.config/mill-version index 767eab027fd..1748b93b64e 100644 --- a/.config/mill-version +++ b/.config/mill-version @@ -1 +1 @@ -0.12.0-RC2 +0.12.0-RC2-9-a527c9 \ No newline at end of file diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 7b185fbece0..ad4e0b85565 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -103,8 +103,8 @@ case class MillCliConfig( disableCallgraph: Flag = Flag(), @arg( doc = - """Select a meta-build level to run the given targets. Level 0 is the normal project, - level 1 the first meta-build, and so on. The last level is a synthetic meta-build used for bootstrapping""" + """Select a meta-level to run the given targets. Level 0 is the main project in `build.mill`, + level 1 the first meta-build in `mill-build/build.mill`, etc.""" ) metaLevel: Option[Int] = None, @arg(doc = "Allows command args to be passed positionally without `--arg` by default") @@ -131,7 +131,7 @@ target cheat sheet: ./mill -i foo.console # run the Scala console for the module `foo` (if it is a ScalaModule) ./mill foo.__.test # run tests in module within `foo` (recursively) -./mill foo.test arg1 arg2 arg3 # run tests in the `foo` module passing in test arguments `arg1 arg2 arg3` +./mill foo.test arg1 arg2 # run tests in the `foo` module passing in test arguments `arg1 arg2` ./mill foo.test + bar.test # run tests in the `foo` module and `bar` module ./mill '{foo,bar,qux}.test' # run tests in the `foo` module, `bar` module, and `qux` module @@ -142,8 +142,8 @@ target cheat sheet: ./mill clean foo.assembly # delete the output of `foo.assembly` to force re-evaluation ./mill clean # delete the output of the entire build to force force re-evaluation -./mill path foo.run foo.sources # print the dependency chain showing how `foo.run` depends on `foo.sources` -./mill visualize __.compile # show how the various `compile` tasks in each module depend on one another +./mill path foo.run foo.sources # print the task chain showing how `foo.run` depends on `foo.sources` +./mill visualize __.compile # show how the `compile` tasks in each module depend on one another options: """ From 0c315e19c603097eb6b6de8cc12ab997e4da58ab Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 11:54:51 +0800 Subject: [PATCH 06/19] . --- .config/mill-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/mill-version b/.config/mill-version index 1748b93b64e..84d9df3ba5a 100644 --- a/.config/mill-version +++ b/.config/mill-version @@ -1 +1 @@ -0.12.0-RC2-9-a527c9 \ No newline at end of file +0.12.0-RC2 \ No newline at end of file From 94cd2967895875b61fedffc8269333816314045e Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 12:00:37 +0800 Subject: [PATCH 07/19] . --- runner/src/mill/runner/MillCliConfig.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index ad4e0b85565..7ab3d2c4476 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -77,7 +77,7 @@ case class MillCliConfig( help: Flag, @arg( short = 'w', - doc = """Watch and re-run your scripts when they change.""" + doc = """Watch and re-run the given tasks when when their inputs change.""" ) watch: Flag = Flag(), @arg( From 921d96be06b1269c5a3238b3917200508db5cd87 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 12:29:58 +0800 Subject: [PATCH 08/19] . --- example/depth/tasks/2-primary-tasks/build.mill | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/depth/tasks/2-primary-tasks/build.mill b/example/depth/tasks/2-primary-tasks/build.mill index 2aecbf28e78..d6d514d4e41 100644 --- a/example/depth/tasks/2-primary-tasks/build.mill +++ b/example/depth/tasks/2-primary-tasks/build.mill @@ -329,7 +329,7 @@ Expected Signature: run args ... ... -> ./mill --allow-positional-command-args run foo.Foo hello world # this succeeds due to --allow-positional-command-args +> ./mill --allow-positional run foo.Foo hello world # this succeeds due to --allow-positional Foo.value: 31337 args: hello world foo.txt resource: My Example Text From e453205939bc6344c8e77faf9752221919de4b44 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 16:26:05 +0800 Subject: [PATCH 09/19] . --- runner/src/mill/runner/MillCliConfig.scala | 28 +++++++++++++++++++--- runner/src/mill/runner/MillMain.scala | 9 ++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 7ab3d2c4476..2fa1df1123d 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -3,7 +3,9 @@ package mill.runner import mainargs.{Flag, Leftover, arg} case class MillCliConfig( + @deprecated("No longer used", "Mill 0.12.0") @arg( + hidden = true, short = 'h', doc = """(internal) The home directory where Mill looks for config and caches.""" @@ -31,12 +33,25 @@ case class MillCliConfig( doc = """Ring the bell once if the run completes successfully, twice if it fails.""" ) ringBell: Flag = Flag(), + @deprecated("No longer supported, use `--ticker false`", "Mill 0.12.0") + @arg( + hidden = true, + doc = + """Disable ticker log (e.g. short-lived prints of stages and progress bars).""" + ) + disableTicker: Flag, @arg( doc = """Enable ticker log (e.g. short-lived prints of stages and progress bars).""" ) - ticker: Option[Boolean] = None, + @deprecated("No longer supported, use `--ticker false`", "Mill 0.12.0") + @arg( + hidden = true, + doc = + """Enable ticker log (e.g. short-lived prints of stages and progress bars).""" + ) + enableTicker: Option[Boolean] = None, @arg(name = "debug", short = 'd', doc = "Show debug output on STDOUT") debugLog: Flag = Flag(), @arg( @@ -120,7 +135,8 @@ object MillCliConfigParser { val customName: String = s"Mill Build Tool, version ${mill.main.BuildInfo.millVersion}" val customDoc = """ usage: mill [options] [[target [target-options]] [+ [target ...]]] - +""" + val cheatSheet = """ target cheat sheet: ./mill resolve _ # see all top-level tasks and modules ./mill resolve __.compile # see all `compile` tasks in any module (recursively) @@ -153,9 +169,15 @@ options: private[this] lazy val parser: ParserForClass[MillCliConfig] = mainargs.ParserForClass[MillCliConfig] - lazy val usageText: String = + lazy val shortUsageText: String = + customName + + customDoc + + "\nRun `./mill --help` for more details" + + lazy val longUsageText: String = customName + customDoc + + cheatSheet + parser.helpText(customName = "", totalWidth = 100).stripPrefix("\n") + "\nPlease see the documentation at https://mill-build.org for more details" diff --git a/runner/src/mill/runner/MillMain.scala b/runner/src/mill/runner/MillMain.scala index 9ce566835cd..c8666c38b14 100644 --- a/runner/src/mill/runner/MillMain.scala +++ b/runner/src/mill/runner/MillMain.scala @@ -108,7 +108,7 @@ object MillMain { (false, RunnerState.empty) case Right(config) if config.help.value => - streams.out.println(MillCliConfigParser.usageText) + streams.out.println(MillCliConfigParser.longUsageText) (true, RunnerState.empty) case Right(config) if config.showVersion.value => @@ -160,7 +160,10 @@ object MillMain { streams, config, mainInteractive, - enableTicker = config.ticker, + enableTicker = + config.ticker + .orElse(config.enableTicker) + .orElse(Option.when(config.disableTicker.value)(false)), printLoggerState ) if (!config.silent.value) { @@ -176,7 +179,7 @@ object MillMain { (false, stateCache) } else if (!bspMode && config.leftoverArgs.value.isEmpty) { - println(MillCliConfigParser.usageText) + println(MillCliConfigParser.shortUsageText) (true, stateCache) From 28ef9249805615b03e8d4d2d0f7dd135add81ca5 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 16:28:56 +0800 Subject: [PATCH 10/19] . --- runner/src/mill/runner/MillCliConfig.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index b3efe007175..3317156730e 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -75,7 +75,7 @@ case class MillCliConfig( meaning 2 threads less than the number of cores. `1` disables parallelism and `0` (the default) uses 1 thread per core.""" ) - threadCountRaw: Option[Int] = None, + threadCountRaw: Option[String] = None, @arg( name = "import", doc = """Additional ivy dependencies to load into mill, e.g. plugins.""" From 62f5270aaeb48370d1d90322b9d54acd1834b04a Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 16:30:43 +0800 Subject: [PATCH 11/19] . --- runner/src/mill/runner/MillCliConfig.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 3317156730e..aadc384df14 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -134,7 +134,7 @@ import mainargs.ParserForClass object MillCliConfigParser { val customName: String = s"Mill Build Tool, version ${mill.main.BuildInfo.millVersion}" val customDoc = """ -usage: mill [options] [[target [target-options]] [+ [target ...]]] +usage: mill [options] target [target-options] [+ target ...] """ val cheatSheet = """ target cheat sheet: From 380a2ab8eeae605438f6b337fa2265ceac07258f Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 16:39:54 +0800 Subject: [PATCH 12/19] . --- runner/src/mill/runner/MillCliConfig.scala | 43 +++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index aadc384df14..6c3e0ecf40b 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -103,7 +103,7 @@ case class MillCliConfig( silent: Flag = Flag(), @arg( name = "target", - doc = """The name or a pattern of the target(s) you want to build.""" + doc = """The name or a pattern of the tasks(s) you want to build.""" ) leftoverArgs: Leftover[String] = Leftover(), @arg(doc = """Toggle colored output; by default enabled only if the console is interactive""") @@ -118,7 +118,7 @@ case class MillCliConfig( disableCallgraph: Flag = Flag(), @arg( doc = - """Select a meta-level to run the given targets. Level 0 is the main project in `build.mill`, + """Select a meta-level to run the given tasks. Level 0 is the main project in `build.mill`, level 1 the first meta-build in `mill-build/build.mill`, etc.""" ) metaLevel: Option[Int] = None, @@ -134,32 +134,32 @@ import mainargs.ParserForClass object MillCliConfigParser { val customName: String = s"Mill Build Tool, version ${mill.main.BuildInfo.millVersion}" val customDoc = """ -usage: mill [options] target [target-options] [+ target ...] +Usage: mill [options] task [task-options] [+ task ...] """ val cheatSheet = """ -target cheat sheet: - ./mill resolve _ # see all top-level tasks and modules - ./mill resolve __.compile # see all `compile` tasks in any module (recursively) +task cheat sheet: + mill resolve _ # see all top-level tasks and modules + mill resolve __.compile # see all `compile` tasks in any module (recursively) - ./mill foo.bar.compile # compile the module `foo.bar` + mill foo.bar.compile # compile the module `foo.bar` - ./mill foo.run --arg 1 # run the main method of the module `foo` and pass in `--arg 1` - ./mill -i foo.console # run the Scala console for the module `foo` (if it is a ScalaModule) + mill foo.run --arg 1 # run the main method of the module `foo` and pass in `--arg 1` + mill -i foo.console # run the Scala console for the module `foo` (if it is a ScalaModule) - ./mill foo.__.test # run tests in module within `foo` (recursively) - ./mill foo.test arg1 arg2 # run tests in the `foo` module passing in test arguments `arg1 arg2` - ./mill foo.test + bar.test # run tests in the `foo` module and `bar` module - ./mill '{foo,bar,qux}.test' # run tests in the `foo` module, `bar` module, and `qux` module + mill foo.__.test # run tests in module within `foo` (recursively) + mill foo.test arg1 arg2 # run tests in the `foo` module passing in test arguments `arg1 arg2` + mill foo.test + bar.test # run tests in the `foo` module and `bar` module + mill '{foo,bar,qux}.test' # run tests in the `foo` module, `bar` module, and `qux` module - ./mill foo.assembly # generate an executable assembly of the module `foo` - ./mill show foo.assembly # print the output path of the assembly of module `foo` - ./mill inspect foo.assembly # show docs and metadata for the `assembly` task on module `foo` + mill foo.assembly # generate an executable assembly of the module `foo` + mill show foo.assembly # print the output path of the assembly of module `foo` + mill inspect foo.assembly # show docs and metadata for the `assembly` task on module `foo` - ./mill clean foo.assembly # delete the output of `foo.assembly` to force re-evaluation - ./mill clean # delete the output of the entire build to force force re-evaluation + mill clean foo.assembly # delete the output of `foo.assembly` to force re-evaluation + mill clean # delete the output of the entire build to force force re-evaluation - ./mill path foo.run foo.sources # print the task chain showing how `foo.run` depends on `foo.sources` - ./mill visualize __.compile # show how the `compile` tasks in each module depend on one another + mill path foo.run foo.sources # print the task chain showing how `foo.run` depends on `foo.sources` + mill visualize __.compile # show how the `compile` tasks in each module depend on one another options: """ @@ -171,8 +171,9 @@ options: lazy val shortUsageText: String = customName + + "Please enter a task to evaluate" + customDoc + - "\nRun `./mill --help` for more details" + "\nRun `mill --help` for more details" lazy val longUsageText: String = customName + From 3e03c3369f30fd8d25e54b4d89ef08c49534a5a0 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 16:42:17 +0800 Subject: [PATCH 13/19] . --- runner/src/mill/runner/MillCliConfig.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 6c3e0ecf40b..aa38ab249df 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -102,7 +102,7 @@ case class MillCliConfig( ) silent: Flag = Flag(), @arg( - name = "target", + name = "task", doc = """The name or a pattern of the tasks(s) you want to build.""" ) leftoverArgs: Leftover[String] = Leftover(), From 35ded90f7837240cc7e4dac6e2d8fd9497e0caf7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 16:49:13 +0800 Subject: [PATCH 14/19] . --- runner/src/mill/runner/MillCliConfig.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index aa38ab249df..7ae0d97464e 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -146,7 +146,7 @@ task cheat sheet: mill foo.run --arg 1 # run the main method of the module `foo` and pass in `--arg 1` mill -i foo.console # run the Scala console for the module `foo` (if it is a ScalaModule) - mill foo.__.test # run tests in module within `foo` (recursively) + mill foo.__.test # run tests in modules nested within `foo` (recursively) mill foo.test arg1 arg2 # run tests in the `foo` module passing in test arguments `arg1 arg2` mill foo.test + bar.test # run tests in the `foo` module and `bar` module mill '{foo,bar,qux}.test' # run tests in the `foo` module, `bar` module, and `qux` module @@ -171,7 +171,7 @@ options: lazy val shortUsageText: String = customName + - "Please enter a task to evaluate" + + "Please specify a task to evaluate" + customDoc + "\nRun `mill --help` for more details" From 4b16bf3ecf016e10180e38aadacee9738afa43e1 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 16:49:41 +0800 Subject: [PATCH 15/19] . --- runner/src/mill/runner/MillCliConfig.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 7ae0d97464e..16adf540801 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -156,7 +156,7 @@ task cheat sheet: mill inspect foo.assembly # show docs and metadata for the `assembly` task on module `foo` mill clean foo.assembly # delete the output of `foo.assembly` to force re-evaluation - mill clean # delete the output of the entire build to force force re-evaluation + mill clean # delete the output of the entire build to force re-evaluation mill path foo.run foo.sources # print the task chain showing how `foo.run` depends on `foo.sources` mill visualize __.compile # show how the `compile` tasks in each module depend on one another From eebee025412af774bc98fba41d91e6108d442b4e Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 16:51:32 +0800 Subject: [PATCH 16/19] . --- .../ROOT/partials/Intro_to_Mill_Footer.adoc | 96 +++++++++++-------- 1 file changed, 56 insertions(+), 40 deletions(-) diff --git a/docs/modules/ROOT/partials/Intro_to_Mill_Footer.adoc b/docs/modules/ROOT/partials/Intro_to_Mill_Footer.adoc index 254b3f05f6e..fafdc76dada 100644 --- a/docs/modules/ROOT/partials/Intro_to_Mill_Footer.adoc +++ b/docs/modules/ROOT/partials/Intro_to_Mill_Footer.adoc @@ -56,51 +56,67 @@ Tasks that depend on each other can't be processed in parallel. == Command-line usage -Mill is a command-line tool and supports various options. - -Run `mill --help` for a complete list of options +Mill is a command-line tool and supports various options. Run `mill --help` for +a complete list of options and a cheat-sheet of how to work with tasks: .Output of `mill --help` [source,subs="verbatim,attributes"] ---- Mill Build Tool, version {mill-version} -usage: mill [options] [[target [target-options]] [+ [target ...]]] - -D --define Define (or overwrite) a system property. - -b --bell Ring the bell once if the run completes successfully, twice if - it fails. - --bsp Enable BSP server mode. - --color Enable or disable colored output; by default colors are enabled - in both REPL and scripts mode if the console is interactive, and - disabled otherwise. - -d --debug Show debug output on STDOUT - --disable-ticker Disable ticker log (e.g. short-lived prints of stages and - progress bars). - --enable-ticker Enable ticker log (e.g. short-lived prints of stages and - progress bars). - -h --home (internal) The home directory of internally used Ammonite script - engine; where it looks for config and caches. - --help Print this help message and exit. - -i --interactive Run Mill in interactive mode, suitable for opening REPLs and - taking user input. This implies --no-server and no mill server - will be used. Must be the first argument. - --import Additional ivy dependencies to load into mill, e.g. plugins. - -j --jobs Allow processing N targets in parallel. Use 1 to disable - parallel and 0 to use as much threads as available processors. - -k --keep-going Continue build, even after build failures. - --meta-level Experimental: Select a meta-build level to run the given - targets. 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. - --no-server Run Mill in single-process mode. In this mode, no Mill server - will be started or used. Must be the first argument. - -s --silent Make ivy logs during script import resolution go silent instead - of printing; though failures will still throw exception. - -v --version Show mill version information and exit. - -w --watch Watch and re-run your scripts when they change. - target ... The name or a pattern of the target(s) you want to build, - followed by any parameters you wish to pass to those targets. To - specify multiple target names or patterns, use the `+` - separator. +Usage: mill [options] task [task-options] [+ task ...] + +task cheat sheet: + mill resolve _ # see all top-level tasks and modules + mill resolve __.compile # see all `compile` tasks in any module (recursively) + + mill foo.bar.compile # compile the module `foo.bar` + + mill foo.run --arg 1 # run the main method of the module `foo` and pass in `--arg 1` + mill -i foo.console # run the Scala console for the module `foo` (if it is a ScalaModule) + + mill foo.__.test # run tests in modules nested within `foo` (recursively) + mill foo.test arg1 arg2 # run tests in the `foo` module passing in test arguments `arg1 arg2` + mill foo.test + bar.test # run tests in the `foo` module and `bar` module + mill '{foo,bar,qux}.test' # run tests in the `foo` module, `bar` module, and `qux` module + + mill foo.assembly # generate an executable assembly of the module `foo` + mill show foo.assembly # print the output path of the assembly of module `foo` + mill inspect foo.assembly # show docs and metadata for the `assembly` task on module `foo` + + mill clean foo.assembly # delete the output of `foo.assembly` to force re-evaluation + mill clean # delete the output of the entire build to force re-evaluation + + mill path foo.run foo.sources # print the task chain showing how `foo.run` depends on `foo.sources` + mill visualize __.compile # show how the `compile` tasks in each module depend on one another + +options: + -D --define Define (or overwrite) a system property. + --allow-positional Allows command args to be passed positionally without `--arg` by default + -b --bell Ring the bell once if the run completes successfully, twice if it fails. + --bsp Enable BSP server mode. + --color Toggle colored output; by default enabled only if the console is interactive + -d --debug Show debug output on STDOUT + --disable-callgraph Disables fine-grained invalidation of tasks based on analyzing code changes. + If passed, you need to manually run `clean` yourself after build changes. + --help Print this help message and exit. + -i --interactive Run Mill in interactive mode, suitable for opening REPLs and taking user + input. This implies --no-server. Must be the first argument. + --import Additional ivy dependencies to load into mill, e.g. plugins. + -j --jobs The number of parallel threads. It can be an integer e.g. `5` meaning 5 + threads, an expression e.g. `0.5C` meaning half as many threads as available + cores, or `C-2` meaning 2 threads less than the number of cores. `1` disables + parallelism and `0` (the default) uses 1 thread per core. + -k --keep-going Continue build, even after build failures. + --meta-level Select a meta-level to run the given tasks. Level 0 is the main project in + `build.mill`, level 1 the first meta-build in `mill-build/build.mill`, etc. + --no-server Run without a background server. Must be the first argument. + -s --silent Make ivy logs during script import resolution go silent instead of printing + --ticker Enable ticker log (e.g. short-lived prints of stages and progress bars). + -v --version Show mill version information and exit. + -w --watch Watch and re-run the given tasks when when their inputs change. + task ... The name or a pattern of the tasks(s) you want to build. + +Please see the documentation at https://mill-build.org for more details ---- All _options_ must be given before the first target. From 3b0d400c1e565e21eff7a12af4c185823342a4b8 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 17:11:36 +0800 Subject: [PATCH 17/19] . --- integration/feature/scoverage/src/ScoverageTests.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/integration/feature/scoverage/src/ScoverageTests.scala b/integration/feature/scoverage/src/ScoverageTests.scala index 75c78521f9c..b6f19364cd2 100644 --- a/integration/feature/scoverage/src/ScoverageTests.scala +++ b/integration/feature/scoverage/src/ScoverageTests.scala @@ -6,10 +6,12 @@ import utest._ object ScoverageTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { - test("test") - integrationTest { tester => - import tester._ - assert(eval("__.compile").isSuccess) - assert(eval("core[2.13.11].scoverage.xmlReport").isSuccess) + test("test") - retry(3) { + integrationTest { tester => + import tester._ + assert(eval("__.compile").isSuccess) + assert(eval("core[2.13.11].scoverage.xmlReport").isSuccess) + } } } } From 418aaf274bb88e14f42c046344cc584eb4896973 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 17:14:59 +0800 Subject: [PATCH 18/19] . --- runner/src/mill/runner/MillCliConfig.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 16adf540801..53cd2e14d31 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -170,8 +170,7 @@ options: mainargs.ParserForClass[MillCliConfig] lazy val shortUsageText: String = - customName + - "Please specify a task to evaluate" + + "Please specify a task to evaluate" + customDoc + "\nRun `mill --help` for more details" From 5592868f9677deba057b5fce5bfe28d925400b01 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Mon, 16 Sep 2024 17:15:09 +0800 Subject: [PATCH 19/19] . --- runner/src/mill/runner/MillCliConfig.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner/src/mill/runner/MillCliConfig.scala b/runner/src/mill/runner/MillCliConfig.scala index 53cd2e14d31..0c23cc8cca3 100644 --- a/runner/src/mill/runner/MillCliConfig.scala +++ b/runner/src/mill/runner/MillCliConfig.scala @@ -170,7 +170,7 @@ options: mainargs.ParserForClass[MillCliConfig] lazy val shortUsageText: String = - "Please specify a task to evaluate" + + "Please specify a task to evaluate\n" + customDoc + "\nRun `mill --help` for more details"