Skip to content

Commit f6c8791

Browse files
Don't put VCS details in Constants.scala when not needed
This is useful when developing on any of the stubs modules (stubs, runner, test-runner), but this triggers a recompilation of build very often. This is now disabled by default. When developing on the stubs modules, set `local-repo`.developingOnStubModules to true in build.sc, for Mill's watch mode to take into account changes in them.
1 parent b9ea4bc commit f6c8791

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

build.sc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,16 @@ class Build(val crossScalaVersion: String)
233233
""" !sv.startsWith("2.") """
234234
else
235235
"false"
236+
val detailedVersionValue =
237+
if (`local-repo`.developingOnStubModules) s"""Some("${vcsState()}")"""
238+
else "None"
236239
val code =
237240
s"""package scala.build.internal
238241
|
239242
|/** Build-time constants. Generated by mill. */
240243
|object Constants {
241244
| def version = "${publishVersion()}"
242-
| def detailedVersion = "${vcsState()}"
245+
| def detailedVersion: Option[String] = $detailedVersionValue
243246
|
244247
| def scalaJsVersion = "${Deps.scalaJsLinker.dep.version}"
245248
| def scalaNativeVersion = "${Deps.nativeTools.dep.version}"
@@ -613,6 +616,14 @@ class TastyLib(val crossScalaVersion: String) extends ScalaCliCrossSbtModule
613616
}
614617

615618
object `local-repo` extends LocalRepo {
619+
620+
/*
621+
* If you are developing locally on any of the stub modules (stubs, runner, test-runner),
622+
* set this to true, so that Mill's watch mode takes into account changes in those modules
623+
* when embedding their JARs in the Scala CLI launcher.
624+
*/
625+
def developingOnStubModules = false
626+
616627
def stubsModules = {
617628
val javaModules = Seq(
618629
stubs

modules/cli/src/main/scala/scala/cli/commands/About.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class About(isSipScala: Boolean) extends ScalaCommand[AboutOptions] {
1010
def run(options: AboutOptions, args: RemainingArgs): Unit = {
1111
CurrentParams.verbosity = options.verbosity.verbosity
1212
val version = Constants.version
13-
val detailedVersionOpt = Some(Constants.detailedVersion).filter(_ != version)
13+
val detailedVersionOpt = Constants.detailedVersion.filter(_ != version)
1414
val appName =
1515
if (isSipScala) "Scala command"
1616
else "Scala CLI"

0 commit comments

Comments
 (0)