Skip to content

Commit 69ad4de

Browse files
committed
Allow to override internal & user Scala versions for mill builds
1 parent 69841f0 commit 69ad4de

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

DEV.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,18 @@ it accordingly before committing:
290290
For more info about reflection configuration in GraalVM,
291291
check [the relevant GraalVM Reflection docs](https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/Reflection/).
292292

293+
## Overriding Scala versions in Scala CLI builds
294+
295+
It's possible to override the internal Scala version used to build Scala CLI,
296+
as well as the default version used by the CLI itself with Java props.
297+
- `scala.version.internal` - overrides the internal Scala version used to build Scala CLI
298+
- `scala.version.user` - overrides the default Scala version used by the CLI itself
299+
300+
NOTE: remember to run `./mill clean` to make sure the Scala versions aren't being cached anywhere.
301+
302+
```bash
303+
./mill -i clean
304+
./mill -i --define scala.version.internal=3.4.0-RC1-bin-20231012-242ba21-NIGHTLY --define scala.version.user=3.4.0-RC1-bin-20231012-242ba21-NIGHTLY scala version --offline
305+
# Scala CLI version: 1.x.x-SNAPSHOT
306+
# Scala version (default): 3.4.0-RC1-bin-20231012-242ba21-NIGHTLY
307+
```

project/deps.sc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@ object Scala {
99
def scala213 = "2.13.12"
1010
def runnerScala3 = "3.0.2" // the newest version that is compatible with all Scala 3.x versions
1111
def scala3 = "3.3.1"
12-
val allScala2 = Seq(scala213, scala212)
13-
val all = allScala2 ++ Seq(scala3)
14-
val mainVersions = Seq(scala3, scala213)
12+
13+
// The Scala version used to build the CLI itself.
14+
def defaultInternal = sys.props.get("scala.version.internal").getOrElse(scala3)
15+
16+
// The Scala version used by default to compile user input.
17+
def defaultUser = sys.props.get("scala.version.user").getOrElse(scala3)
18+
19+
val allScala2 = Seq(scala213, scala212)
20+
val defaults = Seq(defaultInternal, defaultUser).distinct
21+
val all = (allScala2 ++ Seq(scala3) ++ defaults).distinct
22+
val mainVersions = (Seq(scala3, scala213) ++ defaults).distinct
1523
val runnerScalaVersions = runnerScala3 +: allScala2
1624

1725
def scalaJs = "1.13.2"
@@ -54,12 +62,6 @@ object Scala {
5462
true
5563
}
5664
}
57-
58-
// The Scala version used to build the CLI itself.
59-
def defaultInternal = scala3
60-
61-
// The Scala version used by default to compile user input.
62-
def defaultUser = scala3
6365
}
6466

6567
// Dependencies used in integration test fixtures

0 commit comments

Comments
 (0)