Skip to content

Commit aabbb04

Browse files
authored
Merge pull request #2461 from Gedochao/scala-version-overrides
Allow to override internal & user default Scala versions for `mill` builds
2 parents 44cc8cd + 69ad4de commit aabbb04

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
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: 15 additions & 13 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"
@@ -23,12 +31,14 @@ object Scala {
2331
val max213 = patchVer(scala213)
2432
val max30 = 2
2533
val max31 = 3
26-
val max32 = patchVer(scala3)
34+
val max32 = 2
35+
val max33 = patchVer(scala3)
2736
(8 until max212).map(i => s"2.12.$i") ++ Seq(scala212) ++
2837
(0 until max213).map(i => s"2.13.$i") ++ Seq(scala213) ++
2938
(0 to max30).map(i => s"3.0.$i") ++
3039
(0 to max31).map(i => s"3.1.$i") ++
31-
(0 until max32).map(i => s"3.2.$i") ++ Seq(scala3)
40+
(0 to max32).map(i => s"3.2.$i") ++
41+
(0 until max33).map(i => s"3.3.$i") ++ Seq(scala3)
3242
}
3343

3444
def maxAmmoniteScala212Version = scala212
@@ -52,14 +62,6 @@ object Scala {
5262
true
5363
}
5464
}
55-
56-
// The Scala version used to build the CLI itself.
57-
// We should be able to switch to 3.x when it'll have CPS support
58-
// (for the either { value(…) } stuff)
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)