Skip to content

Releases

v1.19.0

Choose a tag to compare

@Gedochao Gedochao released this 11 Nov 21:17
3540735

Default Scala version is 3.10.1

Scala 3.10.1 is the new default Scala version, and the version Scala CLI itself is built with. The previous default was 3.9.0.

The legacy Scala 3.3 LTS line moves to 3.3.9. Tags such as 3.3.lts stay pinned to the LTS versions configured in the Scala CLI build, so a tag cannot drift ahead of that configuration.

scala-cli -e 'println(scala.util.Properties.versionNumberString)'
# 3.10.1
scala-cli -e 'println(dotty.tools.dotc.config.Properties.simpleVersionString)' -S 3.3.lts --with-compiler
# 3.3.9

Added by @Gedochao in #4623, #4574 and #4576

Built with JDK 25, GraalVM 25 for native images

Scala CLI is now built with JDK 25. The class files it publishes still target older Java versions, so a newer build JDK does not leak into the bytecode or the JDK API the code is allowed to call.

Code Compiler flag Bytecode
Java sources in the main modules --release 17 (was --release 16) 17
Scala sources, other than the Scala 3.3 LTS modules -java-output-version:17 17
runner, test-runner -java-output-version:11, on Scala 3.3 LTS 11
java-test-runner --release 8 8
specification-level -java-output-version:17, on Scala 3.3 LTS 17

runner, test-runner and specification-level stay on Scala 3.3 LTS with -Yfuture-lazy-vals. The JVM launcher still requires Java 17 or newer. Projects you compile with Scala CLI can still target older JVMs, for example with --jvm 11 or --jvm 8.

Native images of Scala CLI are built with GraalVM Community 25.0.2. macOS x64 uses GraalVM 25.0.1, the newest Community build published for that platform.

package --native-image defaults to that same GraalVM. Pass --graalvm-version or --graalvm-java-version to pick another one.

scala-cli --power package --help

Added by @Gedochao in #4593

fmt formats .mill files

scala-cli fmt formats Mill build files (.mill), alongside Scala sources and build.sbt. Pass a file or a directory.

version = "3.11.5"
runner.dialect = scala3
package build
import mill.*, scalalib.*
object foo    extends   ScalaModule:
  def scalaVersion    =       "3.3.6"
scala-cli fmt mill-fmt
cat mill-fmt/build.mill

Added by @Gedochao in #4554

The config module is now built with Scala 3.9 LTS

As noted before, the config module was bumped to Scala 3.9.0 LTS. It used to be kept at 3.3 LTS for compatibility.

Added by @Gedochao in #4579

⚡ Exposing ports when packaging a Docker image

--docker-exposed-ports and //> using packaging.dockerExposedPorts declare the ports a Docker image exposes. A value can be a single port (8080), a range (9000-9010) or a port with a protocol (53/udp; tcp is used when the protocol is omitted).

//> using packaging.dockerExposedPorts 8080 9000-9010 53/udp

object Hello:
  def main(args: Array[String]): Unit =
    println("Hello")
scala-cli --power package --docker HelloDocker.scala --docker-image-repository hello-docker --docker-exposed-ports 8080 --docker-exposed-ports 53/udp

Added by @Gedochao in #4586

⚡JSPI for Scala.js on Wasm

On the Wasm backend, js.async and js.await use JavaScript Promise Integration. Since Scala.js 1.22 the linker includes them only when JSPI is enabled. Turn it on with --js-wasm-jspi or //> using wasmJspi, together with Wasm output and ES modules. The runtime has to support JSPI as well. Node.js 25 and later enable it by default.

//> using wasm
//> using jsModuleKind es
//> using wasmJspi
import scala.scalajs.js

object Async:
  def main(args: Array[String]): Unit =
    js.async {
      val x = js.await(js.Promise.resolve[Int](21))
      println(s"JSPI ${x * 2}")
    }
scala-cli --power run Async.scala
# JSPI 42

When the Scala.js linker emits several files, the entry module is now chosen deterministically, and a multi-file linked output directory is removed recursively before the next link.

Added by @sideeffffect in #4550, #4548 and #4549

⚡ Publishing on macOS, Linux ARM64 and Windows ARM64

publish setup and github secret create are now supported on MacOS (both Intel and ARM64), Linux ARM64 and Windows ARM64 platforms.

Added by @Gedochao in #4622

Linux ARM64 .deb and .rpm packages

Linux ARM64 already had a native launcher. This release also publishes ARM64 Debian and RPM packages next to the existing x86_64 ones:

They are uploaded to the scala-cli-packages apt and rpm repositories, together with other Linux artifacts.

Added by @Gedochao in #4572

Windows ARM64 launcher and MSI

A Windows ARM64 build is now published:

The x86_64 Windows launcher already runs on Windows 11 ARM through emulation. Windows 10 ARM does not provide that emulation, so it needs this build. The app image is larger than the x86_64 native launcher, because it ships a JVM.

Added by @warcholjakub in #4595

Features

  • Add --js-wasm-jspi and //> using wasmJspi to enable JSPI on Wasm by @sideeffffect in #4550
  • Add arm64 .deb and .rpm artifacts by @Gedochao in #4572
  • Allow exposing ports when packaging through docker by @Gedochao in #4586
  • Build and publish a Windows ARM64 launcher and .msi package by @warcholjakub in #4595
  • Bump libsodiumjni to 1.0.0 (was 0.0.5) & add support for publishing on arm64 runners by @Gedochao in #4622

Fixes

  • Pick the Scala.js entry module deterministically when the linker emits multiple files by @sideeffffect in #4548
  • Remove the multi-file Scala.js linked output directory recursively by @sideeffffect in #4549
  • Prefer classic main methods over JEP 512 ones when inferring the main class by @Gedochao in #4562
  • fix: re-pin lts tags to the Scala 3 LTS versions configured in the build by @Gedochao in #4576
  • Fix cli scaladoc generation by @Gedochao in #4599
  • Don't walk directories on the class path by @lrytz in #4594
  • Don't compile .jar inputs as sources with --server=false by @sideeffffect in #4596
  • Don't fetch a Scala compiler for --java runs with nothing to compile by @sideeffffect in #4597
  • Don't report power-mode-only options as unrecognized arguments by @sideeffffect in #4598

Security

Compatibility

  • refactor: migrate off deprecated coursier API in tests by @Gedochao in #4561
  • config: bump Scala to 3.9.0 LTS (was 3.3.9 LTS) by @Gedochao in #4579
  • Migrate from coursier/publish to scala/scala-publish by @Gedochao in #4588
  • GraalVM 25.0.2, svm 25.0.5.0.3 & JDK 25 (with -release 17) by @Gedochao in #4593
  • Bump libsodiumjni to 1.0.0 (was 0.0.5) & add support for publishing on arm64 runners by @Gedochao in #4622

Documentation

  • docs: update installation methods by @Gedochao in #4567
  • Back port of documentation changes to main by @github-actions[bot] in #4568

Build and internal changes

Read more

v1.18.0

Choose a tag to compare

@Gedochao Gedochao released this 06 Oct 13:07
65126b8

This release is the biggest internal overhaul of Scala CLI in a while. Scala CLI itself is now built with Scala 3 Next, rather than the 3.3 LTS. At the time of this release that means Scala 3.9.0, with the main modules additionally cross-compiled and tested against the Scala 3.10 RCs (currently 3.10.0-RC3).

From now on, Scala CLI will keep being built with the latest Scala Next version, except for the few modules which are locked to an LTS series, as they're consumed by other tools or loaded on the user's class path:

Module Scala version Why
most modules Scala 3 Next (currently 3.9.0) they're only ever used internally, by Scala CLI itself
runner, test-runner 3.3 LTS (with -Yfuture-lazy-vals) they're loaded on the user's class path, so they stay at 3.3 until it reaches its EOL
specification-level 3.3 LTS (with -Yfuture-lazy-vals) it's a dependency for other tools, so it stays at 3.3 until it reaches its EOL
config 3.3 LTS (with -Yfuture-lazy-vals) it's a dependency of other tools (i.e. coursier); it will be bumped to 3.9 LTS in Scala CLI 1.19

The modules which stayed at Scala 3.3 LTS are now compiled with the -Yfuture-lazy-vals compiler option (and an explicit bytecode target: Java 11 for runner and test-runner, Java 17 for the rest). This makes their lazy vals use the newer implementation, which doesn't rely on sun.misc.Unsafe, unlike the legacy one. As a result, they can be used on JDK 24+ without issues, such as the sun.misc.Unsafe deprecation warnings (which will become errors on future JDKs).

//> using jvm 25
object LazyHello:
  lazy val greeting: String = s"Hello from JDK ${Runtime.version.feature}!"
  def main(args: Array[String]): Unit = println(greeting)
scala-cli run jdk-demo
# Hello from JDK 25!

Other noteworthy changes tied to this:

  • The JVM launcher of Scala CLI now requires Java 17 or newer. Support for launching Scala CLI with JDK 11 to 16
    (which used to be handled by downloading JDK 17 and re-launching the CLI with it) has been dropped. Note that this
    only concerns the JVM running Scala CLI itself: the native launchers are not affected, and your code can still be
    compiled for and run with older JVMs (i.e. with --jvm 11 or --jvm 8).
  • The using directives parser now lives in the Scala 3 compiler repository. Scala CLI's own directives-parser
    module has been replaced with the org.scala-lang::scala3-directives-parser artifact, so the //> using directive
    syntax is now parsed by the very same code that's maintained alongside the compiler.
  • The sources have been migrated to newer Scala 3 syntax, where applicable.
  • scala-cli-signing,
    java-class-name and
    scala-js-cli have also been re-built with Scala 3.9 for the purpose
    of this release.

Added by @Gedochao in #4466, #4489 and #4508

Documentation website redesign

The Scala CLI website has been redesigned - now with a refreshed home page, installation page and documentation layout, as well as a better search experience.

Added by @cyp3rius in #4522

fix sub-command improvements

The fix sub-command received a number of improvements in this release.

Deprecated comma separators get removed from using directives

A new built-in rule removes the deprecated comma separators from using directives (it can be turned off with --enable-comma-separators-removal=false).

Directive aliases are retained

fix used to rewrite the directives it moved to project.scala with their canonical names (i.e. //> using dep would become //> using dependency). The aliases are now retained.

--check works for built-in rules, and reports what fails

--check used to only be supported by the scalafix rules. It now works for built-in rules as well, printing a diff of what would have been changed, rather than changing anything.

//> using dep com.lihaoyi::os-lib:0.11.4, com.lihaoyi::pprint:0.9.0
object Main extends App:
  pprint.pprintln(os.pwd.last)
//> using dep com.lihaoyi::upickle:4.1.0
object Utils
scala-cli fix fix-demo --power --check
Running built-in rules...
--- project.scala
+++ <expected fix>
@@ -1,1 +1,2 @@
-
+// Main
+//> using dep com.lihaoyi::os-lib:0.11.4 com.lihaoyi::pprint:0.9.0 com.lihaoyi::upickle:4.1.0
--- Main.scala
+++ <expected fix>
@@ -1,3 +1,2 @@
-//> using dep com.lihaoyi::os-lib:0.11.4, com.lihaoyi::pprint:0.9.0
 object Main extends App:
   pprint.pprintln(os.pwd.last)
--- Utils.scala
+++ <expected fix>
@@ -1,2 +1,1 @@
-//> using dep com.lihaoyi::upickle:4.1.0
 object Utils
built-in rules failed.

Running without --check applies the changes: the commas get removed and the dep alias is kept.

scala-cli fix fix-demo --power
cat fix-demo/project.scala
# // Main
# //> using dep com.lihaoyi::os-lib:0.11.4 com.lihaoyi::pprint:0.9.0 com.lihaoyi::upickle:4.1.0

Pass a custom scalafix version with --scalafix-version, excluded sources are respected

The scalafix version used under the hood can now be overridden with the --scalafix-version option. Additionally, scalafix rules are now only run on the project's sources, so they respect the //> using exclude directive (rather than scanning the whole directory).

rules = [
  DisableSyntax
]
DisableSyntax.noVars = true
//> using exclude legacy
object Counter:
  val count = 0
object Legacy:
  var count = 0 // excluded, so not linted
scala-cli fix lint-demo --power --enable-built-in=false --scalafix-version 0.14.8 --check

Added by @warcholjakub in #4486, #4491, #4492, #4501, #4503 and #4504

Better support for virtual Java inputs

Scala CLI uses java-class-name to figure out the name of the public class of Java sources which don't come from a file (and so don't have a file name): Java snippets passed with --java-snippet, Java sources piped through standard input and Java code blocks in Markdown inputs.
Bumping it to 0.2.0 fixes a number of issues with those:

  • public enums and records with primitive components used to crash java-class-name;
  • package-private classes used to be treated as public in sources with a package clause;
  • JEP 512 compact source files (with unnamed top-level main methods) are now
    better supported.
echo 'public enum Color { RED, GREEN; public static void main(String[] args) { System.out.println(GREEN); } }' | scala-cli run _.java
# GREEN
scala-cli run --java-snippet 'public record Point(int x, int y) { public static void main(String[] args) { System.out.println(new Point(1, 2)); } }'
# Point[x=1, y=2]
scala-cli run --java-snippet 'package demo;
class Helper { static String greet() { return "Hello from a package-private helper!"; } }
public class Main { public static void main(String[] args) { System.out.println(Helper.greet()); } }'
# Hello from a package-private helper!
scala-cli run --jvm 25 --java-snippet 'void main() { System.out.println("Hello from a JEP 512 compact source snippet!"); }'
# Hello from a JEP 512 compact source snippet!

Fixed by @Gedochao in #4521

Features

  • feat: support scalaOrganization for forked Scala toolchains by @warcholjakub in #4479
  • feat: support --check for built-in rules in fix by @warcholjakub in #4486
  • feat: report what fails fix --check for built-in rules by @warcholjakub in #4491
  • feat: add --scalafix-version option to fix by @warcholjakub in #4503
  • feat: remove deprecated comma separators from directives in fix by @warcholjaku...
Read more

Latest launchers

Choose a tag to compare

@alexarchambault alexarchambault released this 13 Aug 11:38
90e9241
Bump postcss-selector-parser from 6.1.2 to 6.1.4 in /website (#4533)

Bumps [postcss-selector-parser](https://github.com/postcss/postcss-selector-parser) from 6.1.2 to 6.1.4.
- [Release notes](https://github.com/postcss/postcss-selector-parser/releases)
- [Changelog](https://github.com/postcss/postcss-selector-parser/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss-selector-parser/compare/v6.1.2...6.1.4)

---
updated-dependencies:
- dependency-name: postcss-selector-parser
  dependency-version: 6.1.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

v1.17.1

Choose a tag to compare

@Gedochao Gedochao released this 17 Sep 10:19
c6fb50d

Java 8+ support in the pure Java test runner

Projects with no Scala on the class path are handled by a dedicated, pure Java test runner. It used to be compiled for
Java 17, which made it impossible to run such tests on an older JVM. It is now compiled for Java 8, so the whole
Java 8+ range is supported again.

//> using test.dep junit:junit:4.13.2
//> using test.dep com.novocode:junit-interface:0.11
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class MyTests {
  @Test
  public void addition() {
    assertEquals(4, 2 + 2);
    System.out.println("Tested on Java " + System.getProperty("java.version") + ", no Scala needed!");
  }
}
scala-cli test java-tests --jvm 8
# Tested on Java 1.8.0_492, no Scala needed!

Previously, the very same invocation would have died while loading the test runner itself:

Exception in thread "main" java.lang.UnsupportedClassVersionError: scala/build/testrunner/JavaDynamicTestRunner has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Note: Support for JDK <17 will likely be gradually deprecated, but running tests with Java 8+ is likely to be kept long-term for the sake of backwards compatibility.

Fixed by @Gedochao in #4473

Fixes

  • Support Java 8+ with Scala CLI's pure Java test runner by @Gedochao in #4473

Build and internal changes

Updates

Full Changelog: v1.17.0...v1.17.1

v1.17.0

Choose a tag to compare

@Gedochao Gedochao released this 08 Sep 12:54
3c94861

Changed defaults to Scala 3.9.0 LTS & lts tags now point at the 3.9 LTS series

Scala 3.9.0 is both the new default Scala version and the first in line of the new Long Term Support series, so the lts version tags
(as passed to -S / --scala-version or the //> using scala directive) now resolve to 3.9 rather than 3.3.
Additionally, <prefix>.lts tags are now recognised for any supported LTS series, which lets you pin the older 3.3 LTS
explicitly.

Tag Before After
lts, 3.lts 3.3.8 3.9.0
lts.rc, 3.lts.rc latest 3.3 RC latest 3.9 RC
lts.nightly, 3.lts.nightly 3.3 nightly 3.9 nightly
3.3.lts, 3.3.lts.rc, 3.3.lts.nightly not recognised the 3.3 series
3.9.lts, 3.9.lts.rc, 3.9.lts.nightly not recognised the 3.9 series
3.7.lts (and other non-LTS <prefix>.lts) not recognised not recognised
scala-cli -e 'println(scala.util.Properties.versionNumberString)' -S lts
# Compiling project (Scala 3.9.0, JVM (25))
# Compiled project (Scala 3.9.0, JVM (25))
# 3.9.0
scala-cli -e 'println(dotty.tools.dotc.config.Properties.simpleVersionString)' -S 3.3.lts --with-compiler
# Compiling project (Scala 3.3.8, JVM (25))
# Compiled project (Scala 3.3.8, JVM (25))
# 3.3.8

Added by @Gedochao in #4442 and #4443

JEP 512 flexible main methods

Scala CLI now recognises and launches JEP 512 main methods when targeting the JVM:
static or instance main methods, with or without a String array parameter, and regardless of whether they are
public. This requires JDK 25 or newer (or JDK 21+ with the --enable-preview Java option), and works for both Scala and Java sources.

//> using jvm 25
class HelloJep512:
  def main(): Unit = println("Hello from a JEP 512 instance main!")
scala-cli run HelloJep512.scala
# Hello from a JEP 512 instance main!

On JDK 21 through 24 the same code runs as long as preview features are enabled:

//> using jvm 21
//> using javaOpt --enable-preview
class HelloJep512:
  def main(): Unit = println("Hello on JDK 21 preview")

Such main methods are also detected when inherited from a Java class or interface:

//> using jvm 25
public abstract class Greeter {
  void main() {
    System.out.println("Hello from an inherited JEP 512 instance main!");
  }
}
public class HelloJava extends Greeter {}
scala-cli run java-demo --main-class HelloJava
# Hello from an inherited JEP 512 instance main!

On older JDKs detection still happens, so instead of a bare No main class found you now get an actionable message:

[error]  No main class found
Class Hello declares a main method that requires JDK 25 or newer (JEP 512); the current JVM is 17.

Note: the default package bootstrap launcher cannot launch JEP 512 main methods as of yet, use --assembly or --library
instead. Scala.js and Scala Native are not supported for those, either.

Added by @Gedochao and @warcholjakub in #4418, #4425, #4424 and #4430

Individual files as resources

It is now possible to pass individual files (and not only directories) as resources via the --resource command line option and the //> using resource. A file passed this way lands at the root of the class path under its own name.

Hello from an individual resource file!
object ReadResource:
  def main(args: Array[String]): Unit =
    val stream = getClass.getClassLoader.getResourceAsStream("greeting.txt")
    println(scala.io.Source.fromInputStream(stream).mkString.trim)
scala-cli run ReadResource.scala --resource greeting.txt
# Hello from an individual resource file!

Note that a single file can now also be passed to the old --resource-dir option and //> using resourceDir directive.

scala-cli run ReadResource.scala --resource-dir greeting.txt
# Hello from an individual resource file!

Added by @Gedochao in #4428

Library JARs from -d destinations ending with .jar

When the destination passed to -d / --compilation-output ends with .jar, Scala CLI now packages the compilation
results as a library JAR (the same contents as package --library) rather than writing class files into a directory
of that name. This mirrors scalac -d out.jar, so it does not require --power.

object Greeter:
  def greeting: String = "Hello from a packaged library JAR!"
scala-cli compile Greeter.scala -d greeter.jar
scala-cli -e 'println(Greeter.greeting)' --extra-jars greeter.jar

Added by @Gedochao in #4426

The //> using exclude directive in .sc scripts

The //> using exclude directive used to be accepted only in the project.scala configuration file. It can now live
in any .sc script instead — still in just one place per project, so it stays unambiguous. When both a project.scala
and scripts declare excludes, the outermost project.scala wins.

this is not valid Scala at all
//> using exclude broken.scala
println("Hello from a script declaring an exclude directive!")
scala-cli run script-demo

Added by @Gedochao in #4429 and #4437

Features

  • Support JEP 512 flexible main methods on JDK 25+ / JDK21+ with --enable-preview by @Gedochao in #4418
  • Auto detect user-created main methods in classes named with the *$_ suffix by @Gedochao in #4424
  • Package --library JAR files when -d is set to a *.jar path by @Gedochao in #4426
  • Allow the //> using exclude directive in an .sc script rather than just project.scala (but still only one place) by @Gedochao in #4429
  • fix: non-public main detection (JEP 512) by @warcholjakub in #4430
  • Add support for passing individual files as resources by @Gedochao in #4428
  • Auto detect main methods inherited from Java sources (including JEP 512 ones) by @Gedochao in #4425
  • Switch lts tags to Scala 3.9 series by @Gedochao in #4443

Fixes

Build and internal changes

Updates

Read more

v1.16.0

Choose a tag to compare

@Gedochao Gedochao released this 03 Aug 12:44
d8e650b

Script wrappers backtick $ identifiers

Scala 3.9+ warns that identifiers containing $ are reserved for internal compiler use. Script wrappers historically
used names such as hello$_, args$ and args$set. Scala CLI now wraps those names in backticks across all script
wrappers, so .sc scripts keep working cleanly on Scala 3.9 and newer.

scala-cli -e 'println("No more $ warnings in 3.9!")' -S 3.9.0-RC4

Added by @Gedochao in #4378

Sloth support (experimental ⚡️)

Scala CLI can now use Sloth to patch Scala 3.0–3.7.x lazy val bytecode for
compatibility with recent JDKs. Libraries built with older Scala 3 releases still rely on the terminally deprecated
sun.misc.Unsafe lazy val implementation, which produces warnings on JDK 24+ and may fail on future JDKs — even when
your own sources already target Scala 3.8+.

Enable Sloth with --sloth / //> using sloth to post-process classpath bytecode, or --sloth-agent /
//> using slothAgent to attach Sloth as a Java agent (for example when running tests).

object HelloSloth:
  lazy val greeting: String = "Hello from Sloth!"
  def main(args: Array[String]): Unit = println(greeting)
scala-cli --power HelloSloth.scala --sloth -S 3.3 --jvm 25

Added by @Gedochao in #4348

Features

Fixes

  • Wrap all names containing $ reserved character in backticks for all script wrappers by @Gedochao in #4378
  • Only prepend snapshot repos for *-SNAPSHOT Bloop versions by @Gedochao in #4393
  • Exclude *.asc signature files from checksums by @Gedochao in #4403

Documentation changes

Build and internal changes

  • Migrate integration tests off the stale com.spotify:docker-client to com.github.docker-java:docker-java* by @Gedochao in #4364
  • Add anti-regression tests for #4339 by @Gedochao in #4376
  • Make sure launcher download job steps are named appropriately on the CI by @Gedochao in #4382
  • Add a [test_skip] override for the CI by @Gedochao in #4385

Updates

New Contributors

Full Changelog: v1.15.0...v1.16.0

v1.15.0

Choose a tag to compare

@Gedochao Gedochao released this 29 Jun 13:45
ebc1847

Default Scala 3.8.4, Scala Native 0.5.12 & Scala.js 1.22.0

This Scala CLI version bumps the default Scala version to 3.8.4, Scala Native to 0.5.12 and Scala.js to 1.22.0.

scala-cli version
# Scala CLI version: 1.15.0
# Scala version (default): 3.8.4
scala-cli -e 'println("Hello from Scala.js 1.22.0!")' --js
# Compiling project (Scala 3.8.4, Scala.js 1.22.0)
# Compiled project (Scala 3.8.4, Scala.js 1.22.0)
# Hello from Scala.js 1.22.0!
scala-cli -e 'println("Hello from Scala Native 0.5.12!")' --native
# Compiling project (Scala 3.8.4, Scala Native 0.5.12)
# Compiled project (Scala 3.8.4, Scala Native 0.5.12)
# Hello from Scala Native 0.5.12!

Scala 3.8.4 was added by @Gedochao in #4299
Scala Native 0.5.12 was added by @WojciechMazur in #4286
Scala.js 1.22.0 was added by @Gedochao in #4344

JShell support in repl

scala-cli repl can now use JShell as its REPL backend, enabled with the --jshell (--jsh) flag. JShell is also picked automatically for pure-Java projects. The project's classpath (including dependencies) is available inside the JShell session, so you can play with your code (and even reference Scala classes via reflection). JShell requires JDK 9 or newer.

package demo;
public class HelloJShell {
  public static String greet() { return "Hello from JShell!"; }
}
System.out.println(demo.HelloJShell.greet());
scala-cli repl demo/HelloJShell.java --jshell --jvm 17 --repl-quit-after-init --repl-init-script-file hi.jsh

Note: It is possible to explicitly disable JShell on pure Java projects and revert to using Scala REPL with --jshell=false.

Added by @Gedochao in #4262

java snippets in Markdown inputs (experimental ⚡️)

Scala CLI can now compile and run java code blocks inside Markdown inputs, mirroring the existing support for scala snippets. A java snippet is treated like a regular .java input (its body is emitted as Java source without any wrapping). As with other Markdown features, this requires --power.

# Java in Markdown

```java
public class HelloMarkdown {
  public static void main(String[] args) {
    System.out.println("Hello from a Java snippet in Markdown!");
  }
}
```
scala-cli --power HelloMarkdown.md

Added by @Gedochao in #4284

WebAssembly support (experimental ⚡️)

Scala CLI can now compile and run Scala.js through the experimental Scala.js WebAssembly backend. Enable it with the --js-emit-wasm flag (or the //> using wasm directive) together with ES module output (--js-module-kind es / //> using jsModuleKind es).

The Wasm output runs on a JavaScript host that embeds a Wasm engine. Scala CLI does not bundle any of these runtimes — you have to install Node.js (the default), Deno or Bun yourself, then select one with --js-runtime. See the Scala.js with Wasm guide for the details and runtime version requirements.

//> using wasm
//> using jsModuleKind es

@main def hello(): Unit = println("Hello from Wasm!")
# Node.js is the default runtime - no runtime flag needed
scala-cli run HelloWasm.scala --power
# run the same Wasm output on Deno
scala-cli run HelloWasm.scala --power --js-runtime deno
# ...or on Bun
scala-cli run HelloWasm.scala --power --js-runtime bun

Added by @lostflydev in #4176

JUnit 5 (Jupiter) support

The test runner now supports JUnit 5 (Jupiter) via the jupiter-interface test interface, for both Scala and pure-Java tests. JUnit 5 requires Java 17 or newer.

//> using test.dep com.github.sbt.junit:jupiter-interface:0.19.0
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.*

class MyJupiterTests {
  @Test
  def addition(): Unit = {
    assertEquals(4, 2 + 2)
    println("Hello from JUnit 5 / Jupiter!")
  }
}
scala-cli test MyJupiterTests.test.scala --jvm 17

Added by @Gedochao in #4304

SBT 2.x export

The export sub-command can now generate SBT 2.x builds (the default SBT version used for the export is now 2.0.0). Pick a specific version with --sbt-version.

@main def hello(): Unit = println("Hello from an SBT 2.x export!")
scala-cli --power export hello.scala --sbt --sbt-version 2.0.0 -o sbt-project
cat sbt-project/project/build.properties

Added by @Gedochao in #4327

Visual Studio 2026 support on Windows

When building Scala Native (or packaging GraalVM native images) on Windows, Scala CLI locates the MSVC toolchain from your Visual Studio installation. It now also detects Visual Studio 2026, and bundles the matching Visual C++ redistributable (vcredist) in the generated MSI installers.

Added by @Gedochao in #4331

Dropped Ammonite support

The Ammonite REPL integration has been removed (it was deprecated back in v1.13.0). The --ammonite (--amm), --ammonite-version and --ammonite-arg options are gone from scala-cli repl; use the default Scala REPL (or the new JShell backend for Java projects) instead.

scala-cli repl --ammonite

Added by @Gedochao in #4283

Features

Fixes

  • Restore BSP base directory to the original workspace regardless of permissions/ownership by @Gedochao in #4273
  • Improve dependency update actionable diagnostic handling for slow/unresponsive custom repositories by @Gedochao in #4272
  • Improve error for when JVM-only dependencies are not found on other platforms by @Gedochao in #4281
  • Don't save duplicate .scalafmt.conf if unnecessary by @Gedochao in #4291

Deprecations and removals

Build and internal changes

  • Compile the directives-parser example in Scala CLI v1.14.0 release notes by @Gedochao in #4278
  • Retire legacy KEYGRIP secret by @Gedochao in #4275
  • update-installation-script, update-centos and update-debian can't run in parallel by @Gedochao in #4277
  • Track threads & futures spawned in integration tests to make sure logs are in chronological order by @Gedochao in #4293
  • Mark Scala 2 nightly tests as flaky by @Gedochao in #4317
  • Disable test parallelism for unit tests on the CI by @Gedochao in #4316
  • Ensure scala-cli.sh logs to stderr by @alexarchambault in #4301
  • Add an extra test for VS detection on Windows + a small refactor by @Gedochao in #4328
  • Cut MacOS integration tests down to just sanity tests by @Gedochao in #4333
  • Add anti-regression tests for #4329 by @Gedochao in #4332
  • Treat Mill wrapper changes as build changes by @Gedochao in #4347

Updates

  • Update scala-cli.sh launcher for 1.14.0 by @github-actions[bot] in #4274
  • Bump the npm-dependencies group in /website with 3 updates by @dependabot[bot] in #4279
  • Bump webpack-dev-server from 5.2.2 to 5.2.4 in /website by @dependabot[bot] in #4280
  • Bump the npm-dependencies group in /website with 2 updates by @dependabot[bot] in #4287
  • Bump scalafmt to 3.11.1 (was 3.11.0) by @Gedochao in #4290
  • Bump Scala 3 Next RC to 3.8.4-RC3 by @Gedochao in https://g...
Read more

v1.14.0

Choose a tag to compare

@Gedochao Gedochao released this 14 May 22:12
1fee08e

Change default Scala Native version to 0.5.11

This Scala CLI version switches the default Scala Native version to 0.5.11.

Added by @Gedochao in #4253

Support for .test.java

*.test.java files are now picked up as test-scope sources automatically, mirroring *.test.scala.
Under the hood, Scala CLI generates a matching .java source (so Example.test.java generates a matching Example.java source), so that javac accepts the public class.

//> using test.dep junit:junit:4.13.2
//> using test.dep com.novocode:junit-interface:0.11
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class ExampleTest {
  @Test public void foo() { assertEquals(4, 2 + 2); }
}
scala-cli test java-junit-example

Added by @Gedochao in #4261.

A toggle to turn auto-IDE-setup off

Build commands (such as compile, run, test) automatically write the BSP configuration under .bsp/ to keep IDE integration in sync.
This behavior can now be disabled per-invocation via --auto-setup-ide=false, or globally via the ide.auto-setup config key.

scala-cli compile java-junit-example --auto-setup-ide=false
# Compile without generating .bsp/ configuration
scala-cli config ide.auto-setup false
# Disable auto-setup-ide globally for all build commands

Added by @Gedochao in #4258.

New directives-parser module

The legacy Java using_directives parser has been replaced with a Scala-rewritten directives-parser module.
This is transparent to users, but resolves long-standing directive parsing issues (#2443, #3019, #2382) and unblocks future improvements to directive handling.

The directives parser can be used as a standalone library, so you can now parse using directives in your own tools and applications with the same logic as Scala CLI.

//> using scala 3
//> using dep org.virtuslab.scala-cli::directives-parser:1.14.0
import scala.cli.parse.UsingDirectivesParser

@main def parseDirectives(): Unit =
  val source =
    """//> using scala 3.7.4
      |//> using dep com.lihaoyi::os-lib:0.11.4
      |//> using options -Wunused:all -deprecation
      |
      |@main def hello() = println("Hello")
      |""".stripMargin
      
  val result = UsingDirectivesParser.parse(source.toCharArray)

  for d <- result.directives do
    val values = d.values.map(_.stringValue).mkString(", ")
    println(s"${d.key} = $values  (line ${d.keyPosition.line})")
    
  if result.diagnostics.nonEmpty then
    println("Diagnostics:")
    result.diagnostics.foreach(println)

Added by @Gedochao in #4192.

Typelevel Toolkit 0.2.0 (with Scala Native)

The Typelevel Toolkit dependency has been bumped to 0.2.0 and is now compatible with Scala Native 0.5.x.
It's worth mentioning that its test framework has been swapped from MUnit to Weaver.

//> using toolkit typelevel:default
//> using platform native

import cats.effect.*
import weaver.*

object HelloSuite extends SimpleIOSuite:
  test("hello") {
    IO("Hello").map(expect.eql(_, "Hello"))
  }

Added by @Gedochao in #4244.

Features

  • Migrate from old using_directives to Scala-rewritten directives-parser module by @Gedochao in #4192
  • Allow to disable auto-setup-ide in build commands with a command line option & config by @Gedochao in #4258
  • Support for .test.java by @Gedochao in #4261

Fixes

  • Prevent duplicate publish.credentials and repositories.credentials from being saved to the config database by @Gedochao in #4257

Build and internal changes

  • Fix scala-cli-archive-keyring.gpg generation; auto generate KEY.gpg for scala-cli-packages by @Gedochao in #4238
  • Fix sclicheck.GifTests.complete-install timing out by @Gedochao in #4236
  • Split the update-packages CI job down into individual targets by @Gedochao in #4259
  • Add explicit overrides in ScalaCliScalafixModule by @Gedochao in #4267

Documentation changes

  • Fix docs & add tests for repositories.mirrors & repositories.default by @Gedochao in #4235

Updates

  • Update scala-cli.sh launcher for 1.13.0 by @github-actions[bot] in #4232
  • Bump @algolia/client-search from 5.50.1 to 5.50.2 in /website in the npm-dependencies group by @dependabot[bot] in #4242
  • Bump @algolia/client-search from 5.50.2 to 5.51.0 in /website in the npm-dependencies group by @dependabot[bot] in #4247
  • Bump postcss from 8.5.6 to 8.5.12 in /website by @dependabot[bot] in #4248
  • Bump the npm-dependencies group in /website with 5 updates by @dependabot[bot] in #4251
  • Bump Mill to 1.1.6 (was 1.1.5) by @Gedochao in #4254
  • Bump Scala Native to 0.5.11 (was 0.5.10) by @Gedochao in #4253
  • Bump Scala 3 Next RC to 3.8.4-RC2 by @Gedochao in #4243
  • Bump fast-uri from 3.1.0 to 3.1.2 in /website by @dependabot[bot] in #4263
  • Bump @babel/plugin-transform-modules-systemjs from 7.28.5 to 7.29.4 in /website by @dependabot[bot] in #4264
  • Bump the npm-dependencies group in /website with 3 updates by @dependabot[bot] in #4265
  • Bump Typelevel Toolkit to 0.2.0 and enable it for Scala Native 0.5.* by @Gedochao in #4244
  • Bump Scala toolkit to 0.9.2 (was 0.8.0) by @Gedochao in #4268
  • Bump coursier to 2.1.25-M25 by @Gedochao in #4266

Full Changelog: v1.13.0...v1.14.0

v1.13.0

Choose a tag to compare

@Gedochao Gedochao released this 15 Apr 12:08
ed37d80

Change default Scala version to 3.8.3

This Scala CLI version switches the default Scala version to 3.8.3.

scala-cli version
# Scala CLI version: 1.13.0
# Scala version (default): 3.8.3

Added by @Gedochao in #4204

Support for Scala.js 1.21.0

This Scala CLI version adds support for Scala.js 1.21.0.

scala-cli -e 'println("Hello")' --js
# Compiling project (Scala 3.8.3, Scala.js 1.21.0)
# Compiled project (Scala 3.8.3, Scala.js 1.21.0)
# Hello

Added by @Gedochao in #4229

Ammonite REPL deprecated & scheduled for removal

The Ammonite-backed REPL integration is now deprecated and planned for removal (in sync with Ammonite's official communication).
Flags such as --ammonite, --ammonite-version, and --ammonite-arg on scala-cli repl will go away in a future release.

It's time to move on to the default Scala REPL.

Added by @Gedochao in #4218

java-test-runner for pure Java tests

Projects with only Java sources (no Scala in the build) now use a dedicated java-test-runner module when running scala-cli test.
The new runner wires up Java-friendly test frameworks (such as JUnit via junit-interface) without pulling the Scala test runner or Scala itself onto the test classpath.

//> using test.dep junit:junit:4.13.2
//> using test.dep com.novocode:junit-interface:0.11
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class JavaTestRunnerExample {
  @Test
  public void foo() {
    assertEquals(4, 2 + 2);
  }
}

Added by @Gedochao in #4197

GraalVM native-image packaging: packaging.graalvmJvmId and packaging.graalvmArgs

GraalVM native-image packaging JVM id and args are now configurable from using directive level.

//> using packaging.packageType graalvm
//> using packaging.graalvmJvmId graalvm-community:23.0.2
//> using packaging.graalvmArgs --no-fallback

Added by @zrhmn in #4223 & #4225

Features

  • Add java-test-runner module to support running tests with pure Java by @Gedochao in #4197
  • Support -opt-inline:help by @Gedochao in #4215
  • Add directive packaging.graalvmJvmId by @zrhmn in #4223
  • Add additional packaging.graalvm* directives by @zrhmn in #4225

Deprecations

  • Add proper deprecation logic for features & deprecate Ammonite for removal by @Gedochao in #4218

Fixes

  • Add signed-by support to Debian APT repository by @Gedochao in #4207
  • Add missing attributes to ivy2 publishing by @Gedochao in #4203
  • Fix misc compiler warnings by @Gedochao in #4220
  • Make each packaged native image use its own subdirectory under nativeImageWorkDir when cross-packaging by @Gedochao in #4221
  • Support formatting .sbt inputs by @Gedochao in #4195

Build and internal changes

  • Skip CI steps irrelevant to committed changes on PRs by @Gedochao in #4208
  • Run tests with JDK 26 by @Gedochao in #4214
  • Split release_notes.md into a separate test per-release-tag in docs-tests by @Gedochao in #4216

Updates

  • Update scala-cli.sh launcher for 1.12.5 by @github-actions[bot] in #4191
  • Bump Scala 3 Next RC to 3.8.3-RC3 by @Gedochao in #4194
  • Bump dorny/test-reporter from 2 to 3 in the github-actions group by @dependabot[bot] in #4198
  • Bump picomatch from 2.3.1 to 2.3.2 in /website by @dependabot[bot] in #4200
  • Bump node-forge from 1.3.3 to 1.4.0 in /website by @dependabot[bot] in #4202
  • Bump Scala 3 Next to 3.8.3 by @Gedochao in #4204
  • Bump brace-expansion from 1.1.12 to 1.1.13 in /website by @dependabot[bot] in #4205
  • Bump @algolia/client-search from 5.49.2 to 5.50.0 in /website in the npm-dependencies group by @dependabot[bot] in #4206
  • Bump the npm-dependencies group in /website with 2 updates by @dependabot[bot] in #4211
  • Bump lodash from 4.17.23 to 4.18.1 in /website by @dependabot[bot] in #4212
  • Bump Scala 3 Next RC to 3.8.4-RC1 by @Gedochao in #4213
  • Bump Mill to 1.1.5 (was 1.1.3) by @Gedochao in #4217
  • Bump the npm-dependencies group in /website with 6 updates by @dependabot[bot] in #4226
  • Bump follow-redirects from 1.15.11 to 1.16.0 in /website by @dependabot[bot] in #4227
  • Bump announced Scala 3 Next RC version to 3.8.4-RC1 by @Gedochao in #4219
  • Bump scalafmt to 3.11.0 (was 3.10.7) by @Gedochao in #4228
  • Bump Scala.js to 1.21.0 by @Gedochao in #4229

New Contributors

Full Changelog: v1.12.5...v1.13.0

v1.12.5

Choose a tag to compare

@Gedochao Gedochao released this 19 Mar 06:08
1491ac3

--cross support for run, package and doc sub-commands (experimental ⚡️)

It is now possible to cross-run, cross-package and cross-generate docs (doc) with the --cross command line
option.

  • run runs each configured combination of Scala version and platform (e.g. JVM, Native, JS) in sequence;
  • package produces one artifact per cross build, with the Scala version and platform in the artifact name;
  • doc generates Scaladoc for each cross target into separate output directories.
//> using scala 3.3 3.8
@main def main() = println("Hello")
scala-cli run cross.scala --cross --power
scala-cli package cross.scala --cross --power
scala-cli doc cross.scala --cross -o doc-out --power

Added by @Gedochao in #3808, #4171 & #4183

Global --offline config key

You can set offline mode globally with the config sub-command, so Scala CLI uses the cache and skips network access
without passing --offline every time.

scala-cli config offline true

Added by @Gedochao in #3216

Watch extra paths with --watching (experimental ⚡️)

Use the --watching option or //> using watching to have --watch re-run when files or directories outside
your sources change (e.g. config or assets).

scala-cli run . --watch --power --watching ./config --watching ./assets

Or in source:

//> using watching ./config ./assets

Added by @Gedochao in #4174

Local .m2 in publish local (experimental ⚡️)

publish local now publishes to your local Maven repository (~/.m2), so other local projects can depend
on the published artifacts via Maven coordinates.

scala-cli publish local . --m2 --power

Added by @Gedochao in #4179

Features

Fixes

  • Use Java 17 mapping when generating docs with Scala 3.8+ with doc by @Gedochao in #4180
  • Make test framework discovery on Native more resilient & with better errors by @Gedochao in #4185
  • Warn when .java & .scala sources are used in a mixed compilation with --server=false by @Gedochao in #4181

Build and internal changes

Updates

  • Bump the npm-dependencies group in /website with 3 updates by @dependabot[bot] in #4165
  • Bump the github-actions group with 3 updates by @dependabot[bot] in #4164
  • Update scala-cli.sh launcher for 1.12.4 by @github-actions[bot] in #4166
  • Bump svgo from 3.3.2 to 3.3.3 in /website by @dependabot[bot] in #4168
  • Bump immutable from 5.1.4 to 5.1.5 in /website by @dependabot[bot] in #4167
  • Bump Mill to 1.1.3 (was 1.1.2) by @Gedochao in #4169
  • Bump @algolia/client-search from 5.49.1 to 5.49.2 in /website in the npm-dependencies group by @dependabot[bot] in #4173
  • Bump the github-actions group with 4 updates by @dependabot[bot] in #4172
  • Update Scala 3 Next RC to 3.8.3-RC2 by @Gedochao in #4175
  • Bump undici from 7.18.2 to 7.24.1 in /website by @dependabot[bot] in #4182
  • Bump webfactory/ssh-agent from 0.9.1 to 0.10.0 in the github-actions group by @dependabot[bot] in #4187
  • Bump coursier to 2.1.25-M24 by @Gedochao in #4184
  • Bump sass from 1.97.3 to 1.98.0 in /website in the npm-dependencies group by @dependabot[bot] in #4188

Full Changelog: v1.12.4...v1.12.5