Release notes
v1.5.4
Hotfix release
Although Scala CLI 1.5.4 includes a few updates and improvements, it is primarily a hotfix release for versions 1.5.2 and 1.5.3, which due to technical limitations weren't available on some of our distribution channels.
For extra context refer to:
Support for Scala Native 0.5.6
This Scala CLI version switches the default Scala Native version to 0.5.6.
scala-cli -e 'println("Hello from Scala Native 0.5.6!")' --native
# Compiling project (Scala 3.5.2, Scala Native 0.5.6)
# Compiled project (Scala 3.5.2, Scala Native 0.5.6)
# [info] Linking (multithreadingEnabled=true, disable if not used) (949 ms)
# [info] Discovered 887 classes and 5408 methods after classloading
# [info] Checking intermediate code (quick) (40 ms)
# [info] Multithreading was not explicitly enabled - initial class loading has not detected any usage of system threads. Multithreading support will be disabled to improve performance.
# [info] Linking (multithreadingEnabled=false) (285 ms)
# [info] Discovered 499 classes and 2500 methods after classloading
# [info] Checking intermediate code (quick) (7 ms)
# [info] Discovered 478 classes and 1914 methods after optimization
# [info] Optimizing (debug mode) (429 ms)
# [info] Produced 9 LLVM IR files
# [info] Generating intermediate code (296 ms)
# [info] Compiling to native code (1464 ms)
# [info] Linking with [pthread, dl]
# [info] Linking native code (immix gc, none lto) (208 ms)
# [info] Postprocessing (0 ms)
# [info] Total (3728 ms)
# Hello from Scala Native 0.5.6!
Fixes
- Pin Fedora docker image at
fedora:40
by @Gedochao in #3283 - Don't fail the
update-packages
andwindows-packages
jobs on individual distributions' steps by @Gedochao in #3288
Documentation changes
- Fix broken example in
//> using dep
reference doc by @Gedochao in #3281 - Mention distribution limitations in the Scala CLI 1.5.3 release notes by @Gedochao in #3286
- Back port of documentation changes to main by @github-actions in #3287
Updates
- Update
mill-native-image
to 0.1.29 by @Gedochao in #3278 - Update expecty to 0.17.0 by @scala-steward in #3277
- Update Bloop to 2.0.5 by @Gedochao in #3276
- Update dependency to 0.2.5 by @scala-steward in #3269
- Update
coursier
to 2.1.17 by @Gedochao in #3275 - Update SBT to 1.10.5 by @Gedochao in #3280
- Update
java-class-name
to 0.1.4 by @Gedochao in #3284 - Update scala-cli.sh launcher for 1.5.3 by @Gedochao in #3285
- Update Scala Native to 0.5.6 by @Gedochao in #3295
- Update Mill to 0.11.13 by @Gedochao in #3296
- Update coursier to 2.1.17 for Linux arm64 builds by @Gedochao in #3298
- Update coursier/dependency to 0.3.1 by @Gedochao in #3297
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.5.3...v1.5.4
v1.5.3
This is a hotfix release, which makes all the fixes and enhancements of Scala CLI 1.5.2 available through most standard distribution channels (rather than just Maven Central). For the main release notes, please refer to the v1.5.2 ones.
Distribution limitations
Due to technical difficulties within our release pipeline, Scala CLI 1.5.3 is not available via the following channels:
yum
(on RedHat/Cent OS/Fedora)SDKMAN!
We have followed up with a 1.5.4 hotfix release to address this issue.
Hot-fixes
- Tag failing native packager tests as flaky by @Gedochao in #3270
- Make publishing depend on all integration tests & docs tests by @Gedochao in #3272
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.5.2...v1.5.3
v1.5.2
Scala CLI 1.5.2 will only be available on JVM
Due to technical difficulties with our release pipeline, Scala CLI 1.5.2 was only released as a JVM launcher on Maven Central. While it can be used as such, we followed it up with a hotfix 1.5.3 release, which should be available through all standard distribution channels.
scala-cli --cli-version 1.5.2 --version
# Scala CLI version: 1.5.2
# Scala version (default): 3.5.2
--source
is now deprecated and scheduled for removal in Scala CLI v1.6.x
Due to how easy it is to confuse --source
(the command line option for producing source JARs
with the package
sub-command) and -source
(the Scala compiler option, which can also be passed
as --source
in recent Scala 3 versions), using the former is now deprecated, and will likely be removed
in Scala CLI v1.6.x.
scala-cli --power package --source .
# [warn] The --source option alias has been deprecated and may be removed in a future version.
# (...)
Do note that the deprecation (and future removal) only affects the option alias.
The feature of packaging source JARs remains unchanged.
It is now recommended to switch to using the --src
alias instead.
scala-cli --power package --src .
Support for Scala 3.5.2
This Scala CLI version switches the default Scala version to 3.5.2.
scala-cli version
# Scala CLI version: 1.5.2
# Scala version (default): 3.5.2
(experimental) Initial support for emitting Wasm with a command line option and a directive
It is now possible to emit Wasm via Scala.js with the //> using jsEmitWasm
directive:
//> using platform js
//> using jsEmitWasm
//> using jsModuleKind es
//> using jsModuleSplitStyleStr fewestmodules
println("Hello")
Or with the --js-emit-wasm
command line option:
scala-cli --power package wasm.sc --js --js-emit-wasm
# The `--js-emit-wasm` option is experimental
# Please bear in mind that non-ideal user experience should be expected.
# If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli
# Compiling project (Scala 3.5.2, Scala.js 1.17.0)
# Compiled project (Scala 3.5.2, Scala.js 1.17.0)
# Wrote ~/wasm/wasm.js/main.js, run it with
# node ./wasm.js/main.js
tree wasm.js
# wasm.js
# ├── __loader.js
# ├── main.js
# └── main.wasm
#
# 1 directory, 3 files
For more information about Wasm (WebAssembly) support via Scala.js, refer here.
Features
Deprecations
Fixes
- Fix
--watch
to work correctly with changingusing
directives & sources requiring code generation (scripts, markdown, etc) by @Gedochao in #3218 - Ensure resource directories passed via a using directive aren't ignored in
--watch
mode by @Gedochao in #3221 - Ensure consecutive
-Wconf:*
flags are not ignored by @Gedochao in #3245
Documentation changes
- Mention the
Fix
command in theUsing directives
guide by @dabrowski-adam in #3239 - Back port of documentation changes to main by @github-actions in #3242
Updates
- Update scala-cli.sh launcher for 1.5.1 by @github-actions in #3217
- Update sttp to 3.10.0 by @scala-steward in #3219
- Update asm to 9.7.1 by @scala-steward in #3223
- Update bloop-rifle_2.13 to 2.0.3 by @scala-steward in #3225
- Update bloop-config_2.13 to 2.1.0 by @scala-steward in #3228
- chore: Update next to 3.5.2-RC2 by @tgodzik in #3224
- Update
coursier
to 2.1.14 by @scala-steward in #3226 - Update core_2.13 to 3.10.1 by @scala-steward in #3229
- Update
os-lib
to 0.11.2 by @Gedochao in #3232 - Update sbt, scripted-plugin to 1.10.3 by @scala-steward in #3235
- Update dependency to 0.2.4 by @scala-steward in #3234
- Bump Scala Next to 3.5.2 by @Gedochao in #3230
- Update os-lib to 0.11.3 by @scala-steward in #3240
- Set Scala 3.5.2 as the latest announced Scala Next version by @Gedochao in #3243
- Set Scala 3.6.1 as the Next RC version (which it effectively is) by @Gedochao in #3244
- Update dependencies in
gh-action.md
examples by @kubukoz in #3249 - Bump
scala-js-cli
to 1.17.0.1 by @Gedochao in #3252
New Contributors
- @dabrowski-adam made their first contribution in #3239
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.5.1...v1.5.2
v1.5.1
Support for Scala 3.5.1, 3.3.4, 2.13.15 and 2.12.20
This Scala CLI version switches the default Scala version to 3.5.1.
scala-cli version
# Scala CLI version: 1.5.1
# Scala version (default): 3.5.1
It has also been tested with Scala 3.3.4, 2.13.15 and 2.12.20. The Scala CLI internals are now built with Scala 3.3.4.
Features
Fixes
- improvement: Use distinct on ScalacOpt by @tgodzik in #3139
- bugfix: Check if last segment of path exists by @tgodzik in #3131
- bugfix: Fix duplicate options detection by @tgodzik in #3151
- bugfix: Also deduplicate if options split by space by @tgodzik in #3154
- Fix
setup-ide
for--cli-version
by @Gedochao in #3161 - Ensure main classes from inputs take precedence before those found in JARs added to the class path by @Gedochao in #3165
- Ensure that passing Java props into Scala CLI as launcher args would also pass it into BSP configuration by @Gedochao in #3169
- NIT fixes for the
export
sub-command by @Gedochao in #3197 - Ensure
--version
passed to the default command works with--offline
by @Gedochao in #3207
Documentation changes
- Docs: Fix suppress option for directives-in-multiple-files warning by @mims-github in #3133
- Doc: Tips on how to list available JVMs using coursier by @jatcwang in #3129
- Back port of documentation changes to main by @github-actions in #3160
- Use Scala 3 in the Scala Native gif by @Gedochao in #3195
Build and internal changes
- Add tests for
setup-ide
with--cli-version
by @Gedochao in #3163 - Change how help is referenced to avoid initialization oddness & update
case-app
to 2.1.0-M29 by @coreyoconnor in #3152 - Adjust tests for Scala 3.3.4 by @Gedochao in #3164
- NIT Refactor existing
--watch
tests by @Gedochao in #3175 - Generate an empty JUnit report when no tests were run, rather than fail by @Gedochao in #3179
- NIT Extract REPL tests relying on Ammonite into dedicated traits by @Gedochao in #3209
Updates
- Update scala-cli.sh launcher for 1.5.0 by @github-actions in #3125
- Bump webpack from 5.89.0 to 5.94.0 in /website by @dependabot in #3136
- Bump micromatch from 4.0.5 to 4.0.8 in /website by @dependabot in #3135
- Update os-lib to 0.10.5 by @scala-steward in #3140
- Update Scala Next latest announced version to 3.5.0 by @Gedochao in #3145
- Update Scala 2.12 to 2.12.20 by @Gedochao in #3144
- Update Scala CLI as
scala
related docs by @Gedochao in #3155 - Update os-lib to 0.10.6 by @scala-steward in #3159
- Update coursier to 2.1.11 by @scala-steward in #3166
- Update coursier to 2.1.12 by @scala-steward in #3174
- Update ammonite to 3.0.0-M2-30-486378af by @scala-steward in #3172
- Update sbt to 1.10.2 by @scala-steward in #3180
- Update munit to 1.0.2 by @scala-steward in #3176
- Bump
scala-cli-signing
to 0.2.4 by @Gedochao in #3183 - Bump
coursier
to 2.1.13 andmill-native-image
to 0.1.26 by @Gedochao in #3182 - Update Scala Next to 3.5.1 by @Gedochao in #3190
- Update Scala 3 Next RC to 3.5.2-RC1 by @scala-steward in #3187
- Update Scala 2.13 to 2.13.15 by @Gedochao in #3201
- Update guava to 33.3.1-jre by @scala-steward in #3203
- chore: Update Bloop to 2.0.2 by @tgodzik in #3192
- Update Scala 3 LTS to 3.3.4 by @Gedochao in #3208
- Set Scala 3.5.1 as the latest announced version by @Gedochao in #3206
New Contributors
- @mims-github made their first contribution in #3133
- @jatcwang made their first contribution in #3129
- @coreyoconnor made their first contribution in #3152
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.5.0...v1.5.1
v1.5.0
Support for Scala 3.5.0
This Scala CLI version switches the default Scala version to 3.5.0.
scala-cli version
# Scala CLI version: 1.5.0
# Scala version (default): 3.5.0
Support for Scala Native 0.5.5
This Scala CLI version switches the default Scala Native version to 0.5.5.
scala-cli -e 'println("Hello from Scala Native 0.5.5!")' --native
# Compiling project (Scala 3.5.0, Scala Native 0.5.5)
# Compiled project (Scala 3.5.0, Scala Native 0.5.5)
# [info] Linking (multithreadingEnabled=true, disable if not used) (894 ms)
# [info] Discovered 888 classes and 5407 methods after classloading
# [info] Checking intermediate code (quick) (31 ms)
# [info] Multithreading was not explicitly enabled - initial class loading has not detected any usage of system threads. Multithreading support will be disabled to improve performance.
# [info] Linking (multithreadingEnabled=false) (299 ms)
# [info] Discovered 499 classes and 2497 methods after classloading
# [info] Checking intermediate code (quick) (5 ms)
# [info] Discovered 478 classes and 1912 methods after optimization
# [info] Optimizing (debug mode) (403 ms)
# [info] Produced 9 LLVM IR files
# [info] Generating intermediate code (368 ms)
# [info] Compiling to native code (1565 ms)
# [info] Linking with [pthread, dl]
# [info] Linking native code (immix gc, none lto) (83 ms)
# [info] Postprocessing (0 ms)
# [info] Total (3625 ms)
# Hello from Scala Native 0.5.5!
(⚡️ experimental) Support for exporting to a Maven project
It is now possible to export a Scala CLI project to Maven.
scala-cli export --script-snippet 'println("No need to create the pom.xml yourself!")' --mvn --power -o mvn-demo
# Some utilized features are marked as experimental:
# - `export` sub-command
# - `--mvn` option
# Please bear in mind that non-ideal user experience should be expected.
# If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli
# Exporting to a maven project...
# Exported to: ~/scala-cli-tests/mvn-demo
cd mvn-demo
mvn scala:run -DmainClass=snippet_sc
# (...)
# No need to create the pom.xml yourself!
# [INFO] ------------------------------------------------------------------------
# [INFO] BUILD SUCCESS
# [INFO] ------------------------------------------------------------------------
# [INFO] Total time: 2.589 s
# [INFO] Finished at: 2024-08-22T12:08:36+02:00
# [INFO] ------------------------------------------------------------------------
Added by @yadavan88 in #3003.
Support for launching apps from dependencies without other inputs
It is now possible to launch an app by just specifying its dependency, without the need to provide any source files.
In such a case the build server will not be started, as there's no compilation to be done.
There's also no need to specify the main class, as it's now being detected automatically in dependencies as well.
Do note that explicitly calling the run
sub-command is necessary here, as otherwise Scala CLI will default to the REPL.
scala-cli run --dep io.get-coursier:coursier-cli_2.13:2.1.10 -- version
# 2.1.10
This can be used similarly to Coursier's cs launch
.
Added by @kasiaMarek in #3079.
(⚡️ experimental) JMH available in various commands and via using
directives
Some improvements have been done to the experimental support for JMH (Java Microbenchmark Harness).
The --jmh
and --jmh-version
options can now be passed to a number of commands:
run
, as it was before (note that when--jmh
is passed torun
, the project's main class will default to running the benchmarks rather than the project's default main method; this behaviour is likely to be changed in future versions);compile
, so that a Scala CLI project with benchmarking can be compiled separately from being run;package
, although the resulting artifacts will run the project as normal for now, rather than benchmarks;setup-ide
, so that benchmarking projects can be imported to your IDE of choice;test
andexport
will now also no longer fail with--jmh
, although no specific implementations for benchmarking are in place there yet.
It is now also possible to control JMH with using
directives:
//> using jmh
allows to enable JMH for the project, being the equivalent of the--jmh
option.//> using jmhVersion <version>
allows to set the JMH version to use, being the equivalent of the--jmh-version
option.
//> using jmh
//> using jmhVersion 1.37
package bench
import org.openjdk.jmh.annotations.*
import java.util.concurrent.TimeUnit
@BenchmarkMode(Array(Mode.AverageTime))
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 100, timeUnit = TimeUnit.MILLISECONDS)
@Fork(0)
class Benchmarks {
@Benchmark
def foo(): Unit = {
(1L to 1000L).sum
}
}
Expect more improvements in this area in the future. Also, do play with it and give us feedback about the current implementation!
Added by @Gedochao in #3091 and #3118.
Support for auto-completions in fish
We now have command line auto-completions for the fish
shell.
Added by @KristianLentino99 in #3104.
--js-es-module-import-map
no longer requires --power
mode
A bit of a minor thing, but you can now use the --js-es-module-import-map
option without enabling --power
mode.
Features
- Add support for exporting to a Maven project by @yadavan88 in #3003
- improvement: allow to run main class from deps with no inputs by @kasiaMarek in #3079
- Promote
--js-es-module-import-map
to stable by @Gedochao in #3086 - Tweak benchmarking with JMH by @Gedochao in #3091
- Add support for fish auto-completions by @KristianLentino99 in #3104
- Add directives for JMH by @Gedochao in #3118
Fixes
- bugfix: Exclude sourcecode dependency by @tgodzik in #3094
- bugfix: Exclude both sourcecode and collection-compat correctly by @tgodzik in #3105
- Make package command handle directories in extra classpath by @joan38 in #3096
- Add extra try-catch clause + extra logging in
LocalRepo
by @Gedochao in #3114 - Fix/changing options from sources should not require reload by @MaciejG604 in #3112
- fix: remove the --release flag by @kasiaMarek in #3119
- Remove adding test options to the project/build target name hash by @MaciejG604 in #3107
Internal changes
- Make the
publish
CI job depend onjvm-tests-5
(Scala 3 Next RC test suite) by @Gedochao in #3078 - Include scanning the
.exe
launcher in the release procedure by @Gedochao in #3081 - refactor: Switch to original fork of Bloop by @tgodzik in #3020
- Extract used Java versions to constants by @Gedochao in #3087
- NIT Extract bsp testing utils to a helper trait by @Gedochao in #3092
- Fix/simplify code by @MaciejG604 in #3106
Documentation changes
Updates
- Update scala-cli.sh launcher for 1.4.3 by @github-actions in #3073
- Update bloop-config_2.13 to 2.0.3 by @scala-steward in #3072
- Update Scala toolkit to 0.5.0 by @Gedochao in #3076
- Update Typelevel toolkit to 0.1.27 by @Gedochao in #3077
- Update Scala 3 Next RC to 3.5.0-RC7 by @Gedochao in #3080
- Update bloop-rifle_2.13 to 2.0.0 by @scala-steward in #3108
- Update munit to 1.0.1 by @scala-steward in #3100
- Update Scala 3 Next to 3.5.0 by @Gedochao in #3093
- Update sttp to 3.9.8 by @scala-steward in #3098
- Update guava to 33.3.0-jre by @scala-steward in #3113
- Update slf4j-nop to 2.0.16 by @scala-steward in #3101
- Update Scala 3 Next RC to 3.5.1-RC2 by @scala-steward in #3099
- Update Scala Native to 0.5.5 by @Gedochao in #3117
- Update os-lib to 0.10.4 by @scala-steward in #3121
- Update mill-main to 0.11.12 by @scala-steward in #3120
New Contributors
- @KristianLentino99 made their first contribution in #3104
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.4.3...v1.5.0
v1.4.3
This release is a hotfix for v1.4.2, which due to technical difficulties was not released to Maven Central (and, as an extension, wasn't available as a JAR).
All changes introduced by v1.4.2 are included in this release.
Internal changes
- Ensure the
publish
step to be necessary for updating the native packages upon release by @Gedochao in #3067
Updates
- Update mill-main to 0.11.10 by @scala-steward in #3060
- Update mill-main to 0.11.11 by @Gedochao in #3068
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.4.2...v1.4.3
v1.4.2
v1.4.2 encountered certain difficulties during its release, which made it unavailable on Maven Central. It is recommended to upgrade directly to v1.4.3 or higher, rather than use it.
Environment variable help with --env-help
You can now list environment variables used internally with the --envs-help
flag.
This does include some environment variable used by Scala CLI's dependencies (like Coursier, Bloop, etc.), but should not be treated as an exhaustive list.
scala-cli --env-help --power
# The following is the list of environment variables used and recognized by Scala CLI.
# It should by no means be treated as an exhaustive list.
# Some tools and libraries Scala CLI integrates with may have their own, which may or may not be listed here.
#
# Scala CLI
# SCALA_CLI_CONFIG Scala CLI configuration file path
# SCALA_CLI_HOME Scala CLI home directory
# SCALA_CLI_INTERACTIVE Interactive mode toggle
# SCALA_CLI_INTERACTIVE_INPUTS Interactive mode inputs
# SCALA_CLI_POWER Power mode toggle
# SCALA_CLI_PRINT_STACK_TRACES Print stack traces toggle
# SCALA_CLI_SODIUM_JNI_ALLOW Allow to load libsodiumjni
# SCALA_CLI_VENDORED_ZIS Toggle io.github.scala_cli.zip.ZipInputStream
#
# Java
# JAVA_HOME Java installation directory
# JAVA_OPTS Java options
# JDK_JAVA_OPTIONS JDK Java options
#
# Coursier
# COURSIER_CACHE Coursier cache location
# COURSIER_MODE Coursier mode (can be set to 'offline')
#
# Spark
# SPARK_HOME (power) Spark installation directory
#
# Miscellaneous
# PATH The app path variable
# DYLD_LIBRARY_PATH Runtime library paths on Mac OS X
# LD_LIBRARY_PATH Runtime library paths on Linux
# PATHEXT Executable file extensions on Windows
# SHELL The currently used shell
# VCVARSALL Visual C++ Redistributable Runtimes
# ZDOTDIR Zsh configuration directory
#
# Internal
# CI (power) Marker for running on the CI
Features
- Add environment variable help under
--envs-help
& refactor environment variable usage by @Gedochao in #3055
Fixes
- Fix default scaladoc config, so that id doesn't break all scaladoc links by @KacperFKorban in #3041
- Fix the REPL crashing when a dependency's classpath is called by a macro by @Gedochao in #3043
- Fix Mill export for projects with just the test scope by @Gedochao in #3046
- Ensure
--cli-default-scala-version
is respected by--scalac-help
by @Gedochao in #3048 - Fix
generate-linux-arm64-native-launcher
by @Gedochao in #3053
Internal changes
- Prevent some flaky tests from failing on the CI by @Gedochao in #3049
- Switch to GitHub M1/
aarch64
runners on the CI by @Gedochao in #3050 - Fix Scala 2 nightly test failures by tagging them as flaky or skipping by @Gedochao in #3064
Updates
- Update scala-cli.sh launcher for 1.4.1 by @github-actions in #3039
- Update ammonite to 3.0.0-M2-15-9bed9700 by @scala-steward in #3059
- Update metaconfig-typesafe-config to 0.13.0 by @scala-steward in #3058
- Update semanticdb-shared_2.13.14 to 4.9.9 by @scala-steward in #3063
- Update scalafmt-cli_2.13, scalafmt-core to 3.8.3 by @scala-steward in #3062
- Update os-lib to 0.10.3 by @scala-steward in #3061
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.4.1...v1.4.2
v1.4.1
Pass compiler args as an @argument
file
You can shorten or simplify a Scala CLI command by using an @argument
file to specify a text file that contains compiler arguments.
-d
outputDirectory
The feature may help to work around the Windows command line character limit, among other things, making sure your scripts run on any operating system of your choice.
scala-cli run -e 'println("Hey, I am using an @args file!")' @args.txt
The feature works similarly to the command-line argument files feature of Java 9
and fixes backwards compatibility with the old scala
runner (pre-Scala-3.5.0).
Added by @kasiaMarek in #3012
Explicitly enable or disable multithreading in Scala Native
It is now possible to explicitly enable or disable multithreading in Scala Native builds.
You can do it by setting the //> using nativeMultithreading
directive:
//> using platform native
//> using nativeMultithreading
import scala.concurrent._
import scala.concurrent.duration._
import ExecutionContext.Implicits.global
val promise = Promise[Int]()
val thread = new Thread(new Runnable {
def run(): Unit = {
Thread.sleep(100)
promise.success(42)
}
})
thread.start()
val result = Await.result(promise.future, 2.seconds)
println(result)
Or the --native-multithreading
command line option:
scala-cli run native_multithreading.sc --native --native-multithreading
Features
- Add a command line option & directive for enabling/disabling Scala Native multithreading by @Gedochao in #3011
- feat: allow to pass scalac options using files by @kasiaMarek in #3012
Fixes
- fix for 2954 running script in root dir by @philwalk in #2988
- Pass
javaHome
to Bloop by @kasiaMarek in #2985 - bugfix: Print info diagnostics by @tgodzik in #2990
- Ensure BSP respects --power mode by @Gedochao in #2997
- Add Scala to pure Java test builds by @Gedochao in #3009
- Fix --offline mode for scala-cli as scala installation via coursier by @Gedochao in #3029
Documentation changes
- Fix typo in docs by @ghostdogpr in #2996
- docs: remove
.
from command snippet by @spaceunifyfifty in #2998
Updates
- Update scala-cli.sh launcher for 1.4.0 by @github-actions in #2992
- Update winget-releaser to latest by @vedantmgoyal9 in #2991
- Update ammonite to 3.0.0-M2-13-23a8ef64 by @scala-steward in #2989
- Update Scala 3 Next RC to 3.5.0-RC2 by @scala-steward in #2981
- chore: Bump outdated
javac-semanticdb
plugin to 0.10.0 by @tgodzik in #3004 - Update Scala 3 Next RC to 3.5.0-RC3 by @scala-steward in #3002
- Update sbt to 1.10.1 by @scala-steward in #3015
- Bump Scala 3 Next RC to 3.5.0-RC4 by @Gedochao in #3018
- Swap
scalameta
trees
forsemanticdb-shared
& bumpscalameta
to 4.9.8 by @Gedochao in #3017 - Update Scala 3 Next RC to 3.5.1-RC1 by @scala-steward in #3027
New Contributors
- @vedantmgoyal9 made their first contribution in #2991
- @ghostdogpr made their first contribution in #2996
- @spaceunifyfifty made their first contribution in #2998
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.4.0...v1.4.1
v1.4.0
Running the REPL with the test scope included
It is now possible to start the Scala REPL with access to the test scope.
To do so, it's enough to pass the --test
flag with the repl
sub-command.
package example
object ReplTestScopeExample {
def message: String = "calling test scope from repl"
}
scala-cli repl ReplTestScopeExample.test.scala --test
# Compiling project (test, Scala 3.4.2, JVM (17))
# Compiled project (test, Scala 3.4.2, JVM (17))
# Welcome to Scala 3.4.2 (17, Java OpenJDK 64-Bit Server VM).
# Type in expressions for evaluation. Or try :help.
#
# scala> example.ReplTestScopeExample.message
# val res0: String = calling test scope from repl
#
# scala>
The using jvm
directives are now always respected
Formerly, if the build server (Bloop) was running on an older JVM than the one specified in a using jvm
directive, the directive wouldn't be respected. We now restart the build server based on both the directive and the respective command line option (--jvm
).
//> using jvm 22
//> using javacOpt --enable-preview -Xlint:preview
//> using javaOpt --enable-preview
//> using mainClass Simple
void main() {
System.out.println("Hello from Java 22");
}
Added by @kasiaMarek in #2972
Support for Scala Native 0.5.4
This Scala CLI version adds support for Scala Native 0.5.4. Native platform builds will now use 0.5.4 as the default version.
scala-cli -e 'println("Hello, Scala Native!")' --native
# Compiling project (Scala 3.4.2, Scala Native 0.5.4)
# Compiled project (Scala 3.4.2, Scala Native 0.5.4)
# [info] Linking (multithreadingEnabled=true, disable if not used) (902 ms)
# [info] Discovered 882 classes and 5384 methods after classloading
# [info] Checking intermediate code (quick) (37 ms)
# [info] Multithreading was not explicitly enabled - initial class loading has not detected any usage of system threads. Multithreading support will be disabled to improve performance.
# [info] Linking (multithreadingEnabled=false) (292 ms)
# [info] Discovered 499 classes and 2497 methods after classloading
# [info] Checking intermediate code (quick) (10 ms)
# [info] Discovered 478 classes and 1912 methods after optimization
# [info] Optimizing (debug mode) (445 ms)
# [info] Produced 9 LLVM IR files
# [info] Generating intermediate code (353 ms)
# [info] Compiling to native code (1619 ms)
# [info] Linking with [pthread, dl]
# [info] Linking native code (immix gc, none lto) (137 ms)
# [info] Postprocessing (0 ms)
# [info] Total (3753 ms)
# Hello, Scala Native!
Added by @scala-steward in #2982.
Scala Toolkit 0.4.0 & 0.3.0 defaults
This Scala CLI version treats Scala Toolkit 0.4.0 as the default version under most circumstances.
//> using toolkit default
@main def main() = println(os.pwd)
This unlocks the Scala Toolkit to be used with Scala Native 0.5.x.
scala-cli -e 'println(os.pwd)' --toolkit default --native
# Compiling project (Scala 3.4.2, Scala Native 0.5.4)
# Compiled project (Scala 3.4.2, Scala Native 0.5.4)
# [info] Linking (multithreadingEnabled=true, disable if not used) (1051 ms)
# [info] Discovered 1047 classes and 6745 methods after classloading
# [info] Checking intermediate code (quick) (46 ms)
# [info] Multithreading was not explicitly enabled - initial class loading has not detected any usage of system threads. Multithreading support will be disabled to improve performance.
# [info] Linking (multithreadingEnabled=false) (543 ms)
# [info] Discovered 880 classes and 5417 methods after classloading
# [info] Checking intermediate code (quick) (15 ms)
# [info] Discovered 857 classes and 4238 methods after optimization
# [info] Optimizing (debug mode) (651 ms)
# [info] Produced 9 LLVM IR files
# [info] Generating intermediate code (663 ms)
# [info] Compiling to native code (1621 ms)
# [info] Linking with [pthread, dl]
# [info] Linking native code (immix gc, none lto) (81 ms)
# [info] Postprocessing (0 ms)
# [info] Total (4542 ms)
Scala Native 0.4.x has been dropped in Scala Toolkit 0.4.0 and above, so the last version supporting it, 0.3.0 (and lower), will now make the build default to Scala Native 0.4.17.
scala-cli -e 'println(os.pwd)' --toolkit 0.3.0 --native
# [warn] Scala Toolkit Version(0.3.0) does not support Scala Native 0.5.3, 0.4.17 should be used instead.
# [warn] Scala Native default version 0.5.3 is not supported in this build. Using 0.4.17 instead.
# Compiling project (Scala 3.4.2, Scala Native 0.4.17)
# Compiled project (Scala 3.4.2, Scala Native 0.4.17)
# [info] Linking (900 ms)
# [info] Checking intermediate code (quick) (63 ms)
# [info] Discovered 888 classes and 5298 methods
# [info] Optimizing (debug mode) (836 ms)
# [info] Generating intermediate code (620 ms)
# [info] Produced 10 files
# [info] Compiling to native code (1860 ms)
# [info] Linking with [pthread, dl]
# [info] Total (4406 ms)
# ~/scala-cli-tests
The troublesome case is when Scala Native 0.4.x is passed explicitly, while the Scala Toolkit is set to the default. Scala CLI does not currently support downgrading the Scala Toolkit in this case, and fails the build.
scala-cli -e 'println(os.pwd)' --toolkit default --native --native-version 0.4.17
# Downloading 4 dependencies and 2 internal dependencies
# [error] Error downloading org.scala-lang:toolkit-test_native0.4_3:0.4.0
# [error] not found: ~/.ivy2/local/org.scala-lang/toolkit-test_native0.4_3/0.4.0/ivys/ivy.xml
# [error] not found: https://repo1.maven.org/maven2/org/scala-lang/toolkit-test_native0.4_3/0.4.0/toolkit-test_native0.4_3-0.4.0.pom
# [error] not found: ~/Library/Caches/ScalaCli/local-repo/1.4.0/org.scala-lang/toolkit-test_native0.4_3/0.4.0/ivys/ivy.xml
# [error] No fallback URL found
# [error] COMMAND_LINE
# [error] Error downloading org.scala-lang:toolkit_native0.4_3:0.4.0
# [error] not found: ~/.ivy2/local/org.scala-lang/toolkit_native0.4_3/0.4.0/ivys/ivy.xml
# [error] not found: https://repo1.maven.org/maven2/org/scala-lang/toolkit_native0.4_3/0.4.0/toolkit_native0.4_3-0.4.0.pom
# [error] not found: ~/Library/Caches/ScalaCli/local-repo/1.4.0/org.scala-lang/toolkit_native0.4_3/0.4.0/ivys/ivy.xml
# [error] No fallback URL found
# [error] COMMAND_LINE
Features
Fixes
- Fix BSP IllegalArgumentException when loading project in Metals by @joan38 in #2950
- Don't check for newer CLI versions when the
--cli-version
launcher param is passed (v1.4.0 and onwards, only) by @Gedochao in #2957 - fix: start bloop with jvm version from using directives for JVMs > 17 by @kasiaMarek in #2972
Documentation changes
- Typo fixed in scripts.md by @vaivanov95 in #2974
Internal changes
Updates
- Update scala-cli.sh launcher for 1.3.2 by @github-actions in #2938
- Update Scala Native to 0.5.2 by @scala-steward in #2946
- Update guava to 33.2.1-jre by @scala-steward in #2947
- Update os-lib to 0.10.2 by @scala-steward in #2949
- Update ammonite to 3.0.0-M2-8-ba4429a2 by @scala-steward in #2948
- Update Scala Native to 0.5.3 by @scala-steward in #2951
- Update case-app to 2.1.0-M28 by @scala-steward in #2956
- Update Scala Toolkit to 0.4.0 & dynamically adjust Scala Native defaults by @Gedochao in #2955
- Update munit to 1.0.0 by @scala-steward in #2935
- Update ammonite to 3.0.0-M2-9-88291dd8 by @scala-steward in #2960
- Update
scalameta
to 4.9.6 by @scala-steward in #2967 - Update ammonite to 3.0.0-M2-10-f6e2c001 by @scala-steward in #2965
- Update scalafmt-cli_2.13, scalafmt-core to 3.8.2 by @scala-steward in #2966
- Update scalameta to 4.9.7 by @scala-steward in #2983
- Pin
scala-cli-setup
to v1 and update CI scripts' dependencies by @Gedochao in #2984 - Update Scala Native to 0.5.4 by @scala-steward in #2982
- Update mill-main to 0.11.8 by @scala-steward in #2980
- Update bloop-config_2.13 to 2.0.2 by @scala-steward in #2978
- Update ammonite to 3.0.0-M2-12-951bbc1e by @scala-steward in #2979
New Contributors
- @vaivanov95 made their first contribution in #2974
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.3.2...v1.4.0
v1.3.2
Support for Scala 3.4.2
This Scala CLI version adds support for Scala 3.4.2.
scala-cli version
# Scala CLI version: 1.3.2
# Scala version (default): 3.4.2
Incremental Scala.js linking
Scala CLI now can take advantage of Scala.js' powerful incremental linker, which makes linking very fast for multiple links in a row.
For Scala.js builds, the scala-js-cli
process is now run with the newly added --longRunning
mode.
The process is then reused if the inputs did not change.
Added by @lolgab in #2928 and VirtusLab/scala-js-cli#64.
Features
- Support ARM64 architecture to the launcher script for Mac OS by @carlosedp in #2895
- Incremental Scala.js Linking by @lolgab in #2928
Fixes
- Fix support of multiline shebang by @sierikov in #2908
- Pass scala2-sbt-bridge to Bloop explicitly for Scala 2.13.12+ by @Gedochao in #2927
- Ensure
JAVA_HOME
ofsetup-ide
is respected bybsp
by @Gedochao in #2920 - Improve launcher options handling by @Gedochao in #2931
Documentation changes
- Add docs for
ignore
keyword in snippets in md by @sierikov in #2898 - Back port of documentation changes to main by @github-actions in #2900
- Back port of documentation changes to main by @github-actions in #2910
- Add Scalafmt Cookbook by @sierikov in #2903
- Back port of documentation changes to main by @github-actions in #2914
- remove duplicated word by @naferx in #2915
- Remove unused imports by @naferx in #2916
- corrected instructions for downloading the launcher in Windows (fixes #2921) by @philwalk in #2922
Internal changes
Updates
- Update scala-cli.sh launcher for 1.3.1 by @github-actions in #2894
- Update ammonite to 3.0.0-M1-24-26133e66 by @scala-steward in #2896
- Update ammonite to 3.0.0-M2-1-3763a1d4 by @scala-steward in #2905
- Update scalameta to 4.9.4 by @scala-steward in #2906
- Update Scala Next to 3.4.2 by @Gedochao in #2911
- Update ammonite to 3.0.0-M2-2-741e5dbb by @scala-steward in #2913
- Update os-lib to 0.10.1 by @scala-steward in #2918
- Update
scalameta
to 4.9.5 by @scala-steward in #2919 - Update ammonite to 3.0.0-M2-3-b5eb4787 by @scala-steward in #2917
- Update Scala Next RC to 3.5.0-RC1 by @Gedochao in #2912
- Update bloop-rifle_2.13 to 1.5.17-sc-2 by @scala-steward in #2925
- Update sttp core_2.13 to 3.9.7 by @scala-steward in #2924
- Update ammonite to 3.0.0-M2-4-c3312916 by @scala-steward in #2923
- Bump
scala-js-cli
to v1.16.0.1 by @Gedochao in #2929
New Contributors
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.3.1...v1.3.2
v1.3.1
Scala 2.13.14 Support
This Scala CLI version adds support for Scala 2.13.14.
scala-cli -e 'println(scala.util.Properties.versionNumberString)' -S 2.13
# Compiling project (Scala 2.13.14, JVM (17))
# Compiled project (Scala 2.13.14, JVM (17))
# 2.13.14
Fixes
- Adjust TASTY bump warnings to respect overridden Scala version defaults by @Gedochao in #2888
- Include
scala3-staging
andscala3-tasty-inspector
artifacts when the--with-compiler
option is passed in Scala 3 by @Gedochao in #2889
Internal changes
Updates
- Update scala-cli.sh launcher for 1.3.0 by @github-actions in #2876
- Update Scala 2 to 2.13.14 by @Gedochao in #2882
- Update guava to 33.2.0-jre by @scala-steward in #2883
- Update
com.softwaremill.sttp.client3:core
to 3.9.6 by @scala-steward in #2885 - Update sbt to 1.10.0 by @scala-steward in #2887
- Update ammonite to 3.0.0-M1-19-a7973e17 by @scala-steward in #2884
- Bump
coursier
to 2.1.10 by @Gedochao in #2890
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.3.0...v1.3.1
v1.3.0
Support for Scala Native 0.5.1
This Scala CLI version adds support for Scala Native 0.5.1. All native platform builds will now use 0.5.1 as the default version.
scala-cli -e 'println("Hello, Scala Native!")' --native
# Compiling project (Scala 3.4.1, Scala Native 0.5.1)
# Compiled project (Scala 3.4.1, Scala Native 0.5.1)
# [info] Linking (multithreadingEnabled=true, disable if not used) (1059 ms)
# [info] Discovered 882 classes and 5388 methods after classloading
# [info] Checking intermediate code (quick) (39 ms)
# [info] Multithreading was not explicitly enabled - initial class loading has not detected any usage of system threads. Multithreading support will be disabled to improve performance.
# [info] Linking (multithreadingEnabled=false) (291 ms)
# [info] Discovered 499 classes and 2501 methods after classloading
# [info] Checking intermediate code (quick) (6 ms)
# [info] Discovered 478 classes and 1916 methods after optimization
# [info] Optimizing (debug mode) (432 ms)
# [info] Produced 9 LLVM IR files
# [info] Generating intermediate code (293 ms)
# [info] Compiling to native code (1504 ms)
# [info] Linking with [pthread, dl]
# [info] Linking native code (immix gc, none lto) (351 ms)
# [info] Postprocessing (0 ms)
# [info] Total (4012 ms)
# Hello, Scala Native!
Note that not all the tools Scala CLI integrates with support Scala Native 0.5.x just yet. When such an integration is being used, the default Scala Native version will get downgraded to 0.4.17.
scala-cli -e 'println("Hello, Scala Native!")' --native --toolkit default
# [warn] Scala Toolkit does not support Scala Native 0.5.1, 0.4.17 should be used instead.
# [warn] Scala Native default version 0.5.1 is not supported in this build. Using 0.4.17 instead.
# Compiling project (Scala 3.4.1, Scala Native 0.4.17)
# Compiled project (Scala 3.4.1, Scala Native 0.4.17)
# [info] Linking (1017 ms)
# [info] Checking intermediate code (quick) (53 ms)
# [info] Discovered 743 classes and 4242 methods
# [info] Optimizing (debug mode) (654 ms)
# [info] Generating intermediate code (898 ms)
# [info] Produced 10 files
# [info] Compiling to native code (2039 ms)
# [info] Linking with [pthread, dl]
# [info] Total (4812 ms)
# Hello, Scala Native!
Efforts for supporting Scala Native 0.5.x are ongoing, we expect the downgrade to 0.4.17 in such cases to be a temporary solution.
If you know for a fact that 0.5.x support has been delivered for a tool, you can always pass the --native-version
option explicitly, which will prevent the downgrade.
Fixes
- Add missing Scala 2 compiler print options by @Gedochao in #2848
- Don't recommend
latest
for toolkit version by @keynmol in #2852 - Explicitly pass
scala3-sbt-bridge
to Bloop by @Gedochao in #2873
Internal changes
Updates and maintenance
- Update scala-cli.sh launcher for 1.2.2 by @github-actions in #2847
- Update os-lib to 0.10.0 by @scala-steward in #2854
- Update scala-collection-compat to 2.12.0 by @scala-steward in #2856
- Update slf4j-nop to 2.0.13 by @scala-steward in #2857
- Update pprint to 0.9.0 by @scala-steward in #2855
- Update fansi to 0.5.0 by @scala-steward in #2853
- Update using_directives to 1.1.1 by @scala-steward in #2863
- Update Scala Native to 0.5.1 by @scala-steward and @Gedochao in #2862
- Update
bloop-core
to 1.5.17-sc-1 by @scala-steward in #2873 - Update
bloop-config
to 2.0.0 by @scala-steward in #2873
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.2.2...v1.3.0
v1.2.2
Fixed the Fatal invariant violated
false-positive error coming from Bloop
This small update fixes the Fatal invariant violated
error (#2829).
The error was being thrown by Bloop when running Scala CLI repeatedly with the same sources.
Enhancements
Updates and maintenance
- Update scala-cli.sh launcher for 1.2.1 by @github-actions in #2828
- Update
org.scalameta:trees_2.13
to 4.9.3 by @scala-steward in #2831 - Update ammonite to 3.0.0-M1-10-105f9e32 by @scala-steward in #2844
- Bump
bloop-core
to 1.5.16-sc-2 by @Gedochao in #2837
What's Changed
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.2.1...v1.2.2
v1.2.1
Support for Scala 3.4.1
This Scala CLI version adds support for Scala 3.4.1.
scala-cli version
# Scala CLI version: 1.2.1
# Scala version (default): 3.4.1
Additionally, from this version on Scala CLi is being tested against the latest Scala 3 Next RC. And so, feel free to try out Scala 3.4.2-RC1!
scala-cli run -S 3.4.2-RC1 --with-compiler -e 'println(dotty.tools.dotc.config.Properties.simpleVersionString)'
# Compiling project (Scala 3.4.2-RC1, JVM (17))
# Compiled project (Scala 3.4.2-RC1, JVM (17))
# 3.4.2-RC1
Added by @Gedochao in #2824 & #2822
Support for Scala.js 1.16.0
This version adds Scala CLI support for Scala.js 1.16.0. Added by @scala-steward in #2807 & @Gedochao in scala-js-cli#55.
Fixes
- Fix handling for
-Xlint:help
by @Gedochao in #2781 - Fix
--semanticdb-targetroot
&--semanticdb-sourceroot
for scripts by @Gedochao in #2784 - Adjust actionable diagnostics for scripts by @rochala in #2815
- Fix publishing of runner & test-runner artifacts by @Gedochao in #2819
- bugfix: Fix Bloop import by @tgodzik in #2825
Enhancements
Internal changes
Documentation changes
- Add installation guide for FreeBSD by @spacebanana420 in #2793
- Back port of documentation changes to main by @github-actions in #2797
Updates and maintenance
- Update scala-cli.sh launcher for 1.2.0 by @github-actions in #2783
- Update core_2.13 to 3.9.4 by @scala-steward in #2787
- Update ammonite to 3.0.0-M1-8-35694880 by @scala-steward in #2786
- Update trees_2.13 to 4.9.2 by @scala-steward in #2795
- Update guava to 33.1.0-jre by @scala-steward in #2801
- Bump follow-redirects from 1.15.4 to 1.15.6 in /website by @dependabot in #2803
- Add -unchecked to the list of options that don't require -O by @joan38 in #2800
- Update bloop-rifle_2.13 to 1.5.12-sc-1 by @scala-steward in #2806
- Update sttp.client core to 3.9.5 by @scala-steward in #2810
- Update asm to 9.7 by @scala-steward in #2813
- Update Scala.js to 1.16.0 by @scala-steward in #2807
- Bump express from 4.18.2 to 4.19.2 in /website by @dependabot in #2816
- Update Bloop to 1.5.16-sc-1 by @Gedochao in #2818
- Bump Scala Next to 3.4.1 by @Gedochao in #2822
- Bump Typelevel Toolkit to 0.1.23 by @Gedochao in #2823
New Contributors
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.2.0...v1.2.1
v1.2.0
Scala 3.3.3, 3.4.0, 2.13.13 & 2.12.19 support
This version of Scala CLI adds support for a whooping 4 new Scala versions, it's been busy these past few days!
The default version used when using the CLI will from now on be the Scala 3 Next version (3.4.0 as of this release).
Using the lts
tag will now point to Scala 3.3.3.
The LTS is also the version used for building the internals of Scala CLI (although we now also cross-compile with 3.4.0).
scala-cli version
# Scala CLI version: 1.2.0
# Scala version (default): 3.4.0
Added by @Gedochao in #2772, #2736, #2755, #2753 and #2752
Remapping EsModule imports at link time with Scala.js
Given the following importMap.json
file:
{
"imports": {
"@stdlib/linspace": "https://cdn.skypack.dev/@stdlib/linspace"
}
}
It is now possible to remap the imports at link time with the jsEsModuleImportMap
directive.
//> using jsEsModuleImportMap importMap.json
//> using jsModuleKind es
//> using jsMode fastLinkJS
//> using platform js
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
import scala.scalajs.js.typedarray.Float64Array
object Foo {
def main(args: Array[String]): Unit = {
println(Array(-10.0, 10.0, 10).mkString(", "))
println(linspace(0, 10, 10).mkString(", "))
}
}
@js.native
@JSImport("@stdlib/linspace", JSImport.Default)
object linspace extends js.Object {
def apply(start: Double, stop: Double, num: Int): Float64Array = js.native
}
The same can be achieved with the --js-es-module-import-map
command line option.
scala-cli --power package RemappingEsModuleImports.scala --js --js-module-kind ESModule -o main.js --js-es-module-import-map importMap.json
Added by @Quafadas in #2737 and scala-js-cli#47
Fixes
- Updated method for choosing a free drive letter (fixes #2743) by @philwalk in #2749
- Make sure tasty-lib doesn't warn about Scala 3 Next by @Gedochao in #2775
Enhancements
Internal changes
- Fix overeager Scala version docs tests by @Gedochao in #2750
- Lock script wrapper tests on the internally used Scala 2.13 version by @Gedochao in #2754
- Use Scala LTS as the default version while cross compiling all Scala 3 modules on both LTS & Next by @Gedochao in #2752
- Explicitly set sonatype publishing to use the default cross Scala version by @Gedochao in #2757
- Fix publishing of artifacts to include non-cross-compiled modules by @Gedochao in #2759
- Run integration tests with both Scala 3 LTS & Next versions by @Gedochao in #2760
Documentation changes
- Fix typo by @imRentable in #2739
- Add directive examples in Scala Native docs by @spamegg1 in #2774
- toolkit latest is deprecated, mention default instead by @spamegg1 in #2776
Updates and maintenance
- Update scala-cli.sh launcher for 1.1.3 by @github-actions in #2734
- Bump webfactory/ssh-agent from 0.8.0 to 0.9.0 by @dependabot in #2731
- Update
coursier
to 2.1.9 by @Gedochao in #2735 - Bump
scala-js-cli
to 1.15.0.1 by @Gedochao in #2738 - Update Scala to 3.4.0 by @Gedochao in #2736
- Update slf4j-nop to 2.0.12 by @scala-steward in #2748
- Update trees_2.13 to 4.9.0 by @scala-steward in #2747
- Update mill-main to 0.11.7 by @scala-steward in #2744
- Update sttp client core_2.13 to 3.9.3 by @scala-steward in #2745
- Bump Scala 2.12 to 2.12.19 by @Gedochao in #2753
- Update sbt to 1.9.9 by @scala-steward in #2756
- Bump Scala 2.13 to 2.13.13 by @Gedochao in #2755
- Update scalameta to 4.9.1 by @scala-steward in #2770
- Bump Scala LTS to 3.3.3 by @Gedochao in #2772
- Update ammonite to 3.0.0-M0-71-1e75159e by @scala-steward in #2773
New Contributors
- @imRentable made their first contribution in #2739
- @spamegg1 made their first contribution in #2774
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.1.3...v1.2.0
v1.1.3
Support for LTS Scala version aliases
It is now possible to use lts
and 3.lts
as Scala version aliases in Scala CLI.
They refer to the latest LTS version of Scala (the 3.3.x
line at the time of this release).
scala-cli run -S lts --with-compiler -e 'println(dotty.tools.dotc.config.Properties.simpleVersionString)'
# Compiling project (Scala 3.3.1, JVM (17))
# Compiled project (Scala 3.3.1, JVM (17))
# 3.3.1
Using the 2.lts
, 2.13.lts
& 2.12.lts
aliases returns a meaningful error, too.
scala-cli run -S 2.lts -e 'println(scala.util.Properties.versionString)'
# [error] Invalid Scala version: 2.lts. There is no official LTS version for Scala 2.
# You can only choose one of the 3.x, 2.13.x, and 2.12.x. versions.
# The latest supported stable versions are 2.12.18, 2.13.12, 3.3.1.
# In addition, you can request compilation with the last nightly versions of Scala,
# by passing the 2.nightly, 2.12.nightly, 2.13.nightly, or 3.nightly arguments.
# Specific Scala 2 or Scala 3 nightly versions are also accepted.
# You can also request the latest Scala 3 LTS by passing lts or 3.lts.
Added by @kasiaMarek in #2710
--semanticdb-targetroot
and --semanticdb-sourceroot
options
It is now possible to set the SemanticDB target root and source root directories with unified syntax, independent of the target Scala and/or Java versions.
For a given semanticdb-example.sc
script:
println("SemanticDB targetroot gets set to ./targetRootDir, while sourceroot gets set to the current working directory.")
You now can specify the targetroot
and sourceroot
directories like this:
scala-cli compile src/semanticdb-example.sc --semanticdb-targetroot ./targetRootDir --semanticdb-sourceroot .
Fixes
- remove
user.home
hack by @kasiaMarek in #2710 - Fix ultra-long invalid Scala version errors by @Gedochao in #2724
Documentation changes
- Add information about
--preamble
in assembly packaging documentation by @spacebanana420 in #2713 - Back port of documentation changes to main by @github-actions in #2717
- Documentation for creation of custom toolkit by @yadavan88 in #2715
- Back port of documentation changes to main by @github-actions in #2718
- Fix formatting in custom toolkit doc by @yadavan88 in #2719
- Back port of documentation changes to main by @github-actions in #2720
- Added info about repl with toolkit by @yadavan88 in #2721
- Back port of documentation changes to main by @github-actions in #2723
Updates and maintenance
- Update scala-cli.sh launcher for 1.1.2 by @github-actions in #2688
- Update bsp4j to 2.1.1 by @scala-steward in #2700
- Update Scala Native to 0.4.17 by @scala-steward in #2696
- Bump coursier/setup-action from 1.3.4 to 1.3.5 by @dependabot in #2716
New Contributors
- @kasiaMarek made their first contribution in #2710
- @spacebanana420 made their first contribution in #2713
- @yadavan88 made their first contribution in #2715
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.1.2...v1.1.3
v1.1.2
Support for Scala.js 1.15.0
This version adds Scala CLI support for Scala.js 1.15.0. Added by @scala-steward in #2672 & @Gedochao in scala-js-cli#43.
Fixes
- Fix repeatable compiler options handling from the command line by @Gedochao in #2666
- Fix script wrapper tests & script object wrapper
using
directive by @Gedochao in #2668 - Prevent consecutive
-language:*
options from being ignored by @Gedochao in #2667
Documentation changes
- Fix test.md by @MaciejG604 in #2679
- Back port of documentation changes to main by @github-actions in #2681
Build and internal changes
- Update release procedure steps for
v1.1.x
by @Gedochao in #2665 - Tag
GitHubTests.create secret
as flaky on all Mac tests (including M1) by @Gedochao in #2677
Updates and maintenance
- Update scala-cli.sh launcher for 1.1.1 by @github-actions in #2662
- Bump libsodiumjni to 0.0.4 by @MaciejG604 in #2651
- Update guava to 33.0.0-jre by @scala-steward in #2670
- Update os-lib to 0.9.3 by @scala-steward in #2671
- Update sbt to 1.9.8 by @scala-steward in #2673
- Update trees_2.13 to 4.8.15 by @scala-steward in #2674
- Update slf4j-nop to 2.0.11 by @scala-steward in #2675
- Update Scala.js to 1.15.0 by @scala-steward in #2672
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.1.1...v1.1.2
v1.1.1
Deprecate Scala Toolkit latest
version in favour of default
Using toolkits with the latest
version is now deprecated and will cause a warning.
It will likely be removed completely in a future release.
scala-cli --toolkit latest -e 'println(os.pwd)'
# Using 'latest' for toolkit is deprecated, use 'default' to get more stable behaviour:
# --toolkit default
# Compiling project (Scala 3.3.1, JVM (17))
# Compiled project (Scala 3.3.1, JVM (17))
# /home
It is now advised to either use an explicit toolkit version or rely on the new default
alias.
scala-cli --toolkit default -e 'println(os.pwd)'
# Compiling project (Scala 3.3.1, JVM (17))
# Compiled project (Scala 3.3.1, JVM (17))
# /home
The default
version for toolkits is tied to a particular Scala CLI version.
You can check which version is used by referring to Scala CLI help.
scala-cli version
# Scala CLI version: 1.1.1
# Scala version (default): 3.3.1
scala-cli run -h|grep toolkit
# --toolkit, --with-toolkit version|default Add toolkit to classPath (not supported in Scala 2.12), 'default' version for Scala toolkit: 0.2.1, 'default' version for typelevel toolkit: 0.1.20
Added by @MaciejG604 in #2622
Enhancements
- Remove semantics Compliant for asInstaceOf by @MaciejG604 in #2614
- Scala js mode validation by @MaciejG604 in #2630
- Add missing Scala.js mode aliases by @Gedochao in #2655
- Add deprecation reporting mechanism for using directives by @MaciejG604 in #2622
- Pass java opts to scalac by @MaciejG604 in #2601
Fixes
- Fallback to UTF-8 in setup-ide by @JD557 in #2599
- Separate Scala REPL classpath from user dependencies by @Gedochao in #2607
- Prevent resource directories from breaking sources hash by @Gedochao in #2654
- Fix special handling for the
-Xplugin-list
compiler option by @Gedochao in #2635 - Remove superfluous traits by @MaciejG604 in #2618
- Prevent the toolkit latest deprecation warning from being logged more than once by @Gedochao in #2657
Documentation changes
- Unify mentions of Java properties and link to the correct section of guides. by @MaciejG604 in #2603
- Document script wrappers by @MaciejG604 in #2596
- Shorten titles of cookbooks by @MaciejG604 in #2609
- Add docs for bloop interaction by @MaciejG604 in #2608
- Docs/java opts for compiler by @MaciejG604 in #2619
- Add a subcategories layer for guides & cookbooks by @Gedochao in #2612
- Merge documentations about proxy setup by @MaciejG604 in #2597
- Update test framework versions by @mbovel in #2625
- Back port of documentation changes to main by @github-actions in #2604
- Back port of documentation changes to main by @github-actions in #2611
- Back port of documentation changes to main by @github-actions in #2615
- Back port of documentation changes to main by @github-actions in #2617
- Back port of documentation changes to main by @github-actions in #2620
Build and internal changes
- Add debug mode by @MaciejG604 in #2643
- Downgrade Xcode on macos CI runners by @MaciejG604 in #2632
- Revert xcode version downgrade by @MaciejG604 in #2650
Updates and maintenance
- Update scala-cli.sh launcher for 1.1.0 by @github-actions in #2594
- Update org.eclipse.jgit to 6.8.0.202311291450-r by @scala-steward in #2613
- Bump docusaurus version by @MaciejG604 in #2610
- Bump actions/setup-python from 4 to 5 by @dependabot in #2624
New Contributors
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.1.0...v1.1.1
v1.1.0
Breaking update to Scala 2 scripts
Keep in mind that it ONLY applies to Scala 2! Scala 3 script wrappers are not affected!
Scala CLI now uses a different kind of script wrappers for Scala 2 by default, which support running background threads. This has been introduces as an answer to the issue #2470, where a running a script in Scala 2 would end up in a deadlock due to background threads being run. Also the change makes the Scala 2 scripts run significantly faster, as the code can be optimized due to not residing in the object's initialization clause.
However, the new solution brings some incompatibilities with the old behaviour:
- main classes are now named the same as the file they are defined in, they do not have the '_sc' suffix anymore, so any calls like:
scala-cli foo.sc bar.sc --main-class foo_sc
should be replaced with
scala-cli foo.sc bar.sc --main-class foo
- it is impossible to access the contents of a script named
main.sc
from another source, any references to the script objectmain
will result in a compilation error. E.g. Accessing the contents ofmain.sc
using the following code:
println(main.somethingDefinedInMainScript)
Will result in the following compilation error:
[error] ./foo.sc:2:11
[error] missing argument list for method main in trait App
[error] Unapplied methods are only converted to functions when a function type is expected.
[error] You can make this conversion explicit by writing `main _` or `main(_)` instead of `main`.
When main.sc
is passed as argument together with other scripts, a warning will be displayed:
[warn] Script file named 'main.sc' detected, keep in mind that accessing it from other scripts is impossible due to a clash of `main` symbols
Added by @MaciejG604 in #2556
"Drive relative" paths on Windows
Scala CLI now correctly recognizes "drive relative" paths on Windows, so paths like /foo/bar
will be treated as relative from the root of the current drive - e.g. C:\foo\bar
.
This allows for compatibility of programs referencing paths with e.g. //> using file /foo/bar
with Windows.
UX improvements
- React to some HTTP responses by @MaciejG604 in #2007
- Chore/group warnings about directives in multiple files by @MaciejG604 in #2550
- Migrate to Docusaurus v3, add local search plugin by @MaciejG604 in #2590
Enhancements
- Default to publish repository configured for local machine when inferring publish.ci.repository by @MaciejG604 in #2571
- Skip validation for default Scala versions, add build test by @MaciejG604 in #2576
Fixes
- Take into consideration --project-version when creating BuildInfo by @MaciejG604 in #2548
- Workaround for home.dir property not being set by @MaciejG604 in #2573
- Pass scalac arguments as file by @MaciejG604 in #2584
Documentation changes
- Add a doc on Windows anti-malware submission procedure by @Gedochao in #2546
- Fix list of licenses URL by @JD557 in #2552
- Fix Windows secrets path in the documentation by @JD557 in #2561
- Update the pgp-pair section of publish setup docs by @MaciejG604 in #2565
- Back port of documentation changes to main by @github-actions in #2569
- Document --python flag by @MaciejG604 in #2574
- Document publishing process configuration by @MaciejG604 in #2580
- Back port of documentation changes to main by @github-actions in #2593
Build and internal changes
- Exclude conflicting dependencies by @MaciejG604 in #2541
- Generate test reports on the CI by @Gedochao in #2543
- Use the latest
scala-cli
inmacos-m1-tests
by @Gedochao in #2554 - Install
scala-cli
withcs
on M1 by @Gedochao in #2555 - Fix generating test reports for failed suites by @Gedochao in #2564
- Pin
scala-cli-setup
version to be M1-compatible & use it innative-macos-m1-tests
by @Gedochao in #2568 - Add log separators for integration and build tests by @MaciejG604 in #2570
- Adjust test report generation to mill 0.11.6 bump changes by @Gedochao in #2577
- Bump MacOS CI to
macOS-13
by @Gedochao in #2579 - Add env for configuring home directory overriding by @MaciejG604 in #2587
Updates and maintenance
- Update trees_2.13 to 4.8.13 by @scala-steward in #2532
- Update scala-cli.sh launcher for 1.0.6 by @github-actions in #2542
- chore: Update Bloop to v1.5.11-sc by @tgodzik in #2557
- Update trees_2.13 to 4.8.14 by @scala-steward in #2560
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.17 by @scala-steward in #2559
- Bump VirtusLab/scala-cli-setup from 1.0.5 to 1.0.6 by @dependabot in #2567
- Update ammonite to 3.0.0-M0-59-cdeaa580 by @scala-steward in #2558
- Update mill-main to 0.11.6 by @scala-steward in #2572
- Update coursier-jvm_2.13, ... to 2.1.8 by @scala-steward in #2575
- Update ammonite to 3.0.0-M0-60-89836cd8 by @scala-steward in #2586
- Bump
coursier
tov2.1.8
where it wasn't consistent by @Gedochao in #2588
New Contributors
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.0.6...v1.1.0
v1.0.6
Scala CLI won't default to the system JVM if it's not supported anymore
If your JAVA_HOME
environment variable has been pointing to a JVM that is no longer supported by Scala CLI
(so anything below 17, really), you may have run into an error like this one with Scala CLI v1.0.5:
scala-cli --power bloop exit
# Stopped Bloop server.
export JAVA_HOME=$(cs java-home --jvm zulu:8)
scala-cli -e 'println(System.getProperty("java.version"))'
# Starting compilation server
# Error: bloop.rifle.FailedToStartServerExitCodeException: Server failed with exit code 1
# For more details, please see '/var/folders/5n/_ggj7kk93czdt_n0jzrk8s780000gn/T/1343202731019130640/.scala-build/stacktraces/1699527280-9858975811713766588.log'
# Running
# scala-cli --power bloop output
# might give more details.
This is because we no longer support JVM <17 with Scala CLI v1.0.5, but we still have been defaulting to whatever JVM
was defined in JAVA_HOME
. As a result, Bloop has been failing to start when running with, say, JAVA_HOME
pointing
to Java 8.
This is no longer the case. Scala CLI will now automatically download Java 17 for Bloop in such a situation
(and still use the JVM from JAVA_HOME
for running the code, while Bloop runs on 17).
scala-cli --power bloop exit
# Stopped Bloop server.
export JAVA_HOME=$(cs java-home --jvm zulu:8)
scala-cli -e 'println(System.getProperty("java.version"))'
# Starting compilation server
# Compiling project (Scala 3.3.1, JVM (8))
# Compiled project (Scala 3.3.1, JVM (8))
# 1.8.0_392
Other changes
Fixes
- Fix
--watch
failing on invalidPathWatchers.Event
& skip wonky tests on Mac CI by @Gedochao in #2515 - bugfix: Don't try to always get system jvm first by @tgodzik in #2508
Documentation changes
- Back port of documentation changes to main by @github-actions in #2522
- add cookbook about Emacs integration by @ag91 in #2506
Build and internal changes
- Bump actions/setup-node from 3 to 4 by @dependabot in #2493
- Update scala-cli.sh launcher for 1.0.5 by @github-actions in #2500
- Simplify build by @lolgab in #2512
- Fix wonky native MacOS CI on
stable
branch by @Gedochao in #2518 - Add regexes for release-notes github reference swapping by @MaciejG604 in #2519
Updates and maintenance
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.15 by @scala-steward in #2498
- Switch
lightweight-spark-distrib
to the VL fork & bump to0.0.5
by @Gedochao in #2503 - Bump VirtusLab/scala-cli-setup from 1.0.4 to 1.0.5 by @dependabot in #2504
- Switch
java-class-name
to the VL fork & bump to0.1.3
by @Gedochao in #2502 - Update sbt to 1.9.7 by @scala-steward in #2505
- Update os-lib to 0.9.2 by @scala-steward in #2514
- Update case-app to 2.1.0-M26 by @scala-steward in #2513
- Update mill-main to 0.11.5 by @scala-steward & @MaciejG604 in #2446
- Update core_2.13 to 3.9.1 by @scala-steward in #2521
- Switch
nocrc32-zip-input-stream
to the VL fork & bump it to0.1.2
by @Gedochao in #2520
New Contributors
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.0.5...v1.0.6
v1.0.5
What's new
Accept --power
from anywhere
The --power
flag used to be a launcher option, which means it used to only be accepted when passed
before the sub-command name. Now, it can be passed anywhere in the command line.
scala-cli --power package --help
scala-cli package --power --help
scala-cli package --help --power
Added by @MaciejG604 in #2399
Offline mode (experimental)
It is now possible to run Scala CLI in offline mode for the cases when you don't want the runner
to make any network requests for whatever reason.
This changes Coursier's cache policy to LocalOnly
, preventing it from downloading anything.
scala-cli compile . --offline --power
Of course, this means that you will have to have all the dependencies relevant to your build already downloaded and available in your local cache. Reasonable fallbacks will be used where possible, e.g. the Scala compiler may be used instead of Bloop if Bloop isn't available.
Added by @MaciejG604 in #2404
Shorter install script link
Scala CLI's install script is now available behind a conveniently shorter web address: https://scala-cli.virtuslab.org/get
The fix
sub-command (experimental)
The fix
sub-command is a new addition to Scala CLI. It allows to scan your project for using
directives
and extract them into the project.scala
file placed in the project root directory.
This allows to easily fix warnings tied to having using
directives present in multiple files.
scala-cli fix . --power
Added by @MaciejG604 in #2309
Build static & shared libraries with Scala Native (experimental)
You can now use the --native-target
option to build Scala Native projects as static or shared libraries.
scala-cli package . --power --native-target static
scala-cli package . --power --native-target dynamic
Print platform version
Platform version is now always logged during compilation.
scala-cli compile .
# Compiling project (Scala 3.3.1, JVM (17))
# Compiled project (Scala 3.3.1, JVM (17))
scala-cli compile . --js
# Compiling project (Scala 3.3.1, Scala.js 1.13.2)
# Compiled project (Scala 3.3.1, Scala.js 1.13.2)
scala-cli compile . --native
# Compiling project (Scala 3.3.1, Scala Native 0.4.16)
# Compiled project (Scala 3.3.1, Scala Native 0.4.16)
Other changes
Enhancements
- Accumulate exp warnings with logger by @MaciejG604 in #2376
- Remove ComputeVersion.Command, make ComputeVersion classes positioned by @MaciejG604 in #2350
- Add more configuration for publish by @MaciejG604 in #2435
- Warn about transitive using file directive by @MaciejG604 in #2432
- Support Scala Native 0.5.x changes in publishing artifacts by @WojciechMazur in #2460
Fixes
- Fix - set es version into scala-js-cli by @lwronski in #2351
- Modify the format of StrictDirective.toString by @MaciejG604 in #2355
- Make explicitly passed scala version use the latest release, not the default one by @MaciejG604 in #2411
- Release flag by @lwronski in #2413
- Ensure build resolution is kept when packaging assemblies with provided dependencies by @Gedochao in #2457
- Fix
fmt
sub-command exit code to mirrorscalafmt
by @Gedochao in #2463 - Fix 'JVM too old' as bsp by @MaciejG604 in #2445
- Read java props from env vars by @MaciejG604 in #2356
- Make script wrapper satisfy compiler checks by @MaciejG604 in #2414
- Load local ivy path from ivy.home and user.home system properties by @JD557 in #2484
Documentation changes
- Fix typo in buildInfo directive docs by @izzyreal in #2357
- configuration.md examples "using dep" to current versions by @SunKing2 in #2398
- Documentation updates by @MaciejG604 in #2375
- Fix publish directives usage displayed in one line, unify directive docs by @MaciejG604 in #2381
- Backport of docs change (#2391) by @MaciejG604 in #2403
- Add internal docs for scalajs-cli by @lwronski in #2434
- Add docs for fix command by @MaciejG604 in #2437
- Add docs for offline mode by @MaciejG604 in #2475
- Update dependencies.md to mention jitpack by @doofin in #2458
- Update the list of external repositories Scala CLI depends on by @Gedochao in #2476
- Update the docs to no longer treat --power as a launcher-only option by @Gedochao in #2478
Build and internal changes
- Add test for actionable diagnostics from compiler by @MaciejG604 in #2327
- Pin the versions of Github CI runners by @MaciejG604 in #2370
- Remove bloop timeouts in tests by @MaciejG604 in #2407
- Add post-update hook for reference doc generation by @MaciejG604 in #2406
- Add tests which check availability of scalafmt native launcher for de… by @lwronski in #2418
- Default to a Scala version for REPL if there are no Scala artifacts. by @trilleplay in #2431
- Remove unused snippet checker by @lwronski in #2423
- Allow to override internal & user default Scala versions for
mill
builds by @Gedochao in #2461 - NIT: Refactor: Rely on global --power option where able in cli commands by @Gedochao in #2480
Updates and maintenance
- Update scala-cli.sh launcher for 1.0.4 by @github-actions in #2344
- Update bloop-rifle_2.13 to 1.5.9-sc-2 by @lwronski in #2345
- Update core_2.13 to 3.9.0 by @scala-steward in #2346
- Update sbt to 1.9.3 by @scala-steward in #2349
- Bump VirtusLab/scala-cli-setup from 1.0.2 to 1.0.4 by @dependabot in #2348
- Update coursier-jvm_2.13, ... to 2.1.6 by @scala-steward in #2360
- Update trees_2.13 to 4.8.9 by @scala-steward in #2369
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.13 by @scala-steward in #2368
- Update bloop-rifle_2.13 to 1.5.11-sc-1 by @scala-steward in #2383
- Update org.eclipse.jgit to 6.6.1.202309021850-r by @scala-steward in #2384
- Update trees_2.13 to 4.8.10 by @scala-steward in #2387
- Update coursier-jvm_2.13, ... to 2.1.7 by @scala-steward in #2393
- Bump docker/login-action from 2 to 3 by @dependabot in #2400
- Update org.eclipse.jgit to 6.7.0.202309050840-r by @scala-steward in #2395
- Update scala3-library to 3.3.1 by @scala-steward in #2392
- Update slf4j-nop to 2.0.9 by @scala-steward in #2388
- Update file-tree-views to 2.1.11 by @scala-steward in #2410
- Update test-runner, tools to 0.4.15 by @scala-steward in #2385
- Update scala-library to 2.13.12 by @scala-steward in #2396
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.14 by @scala-steward in #2386
- Update file-tree-views to 2.1.12 by @scala-steward in #2419
- Update bsp4j to 2.1.0-M6 by @scala-steward in #2401
- Update trees_2.13 to 4.8.11 by @scala-steward in #2429
- Update asm to 9.6 by @scala-steward in #2442
- Update bsp4j to 2.1.0-M7 by @scala-steward in #2438
- Update metaconfig-typesafe-config to 0.12.0 by @scala-steward in #2439
- Update ammonite to 3.0.0-M0-56-1bcbe7f6 by @scala-steward in #2440
- Bump Scala Native to 0.4.16 & log platform version by @Gedochao in #2465
- Update guava to 32.1.3-jre by @scala-steward in #2467
- Update trees_2.13 to 4.8.12 by @scala-steward in #2468
- Bump actions/checkout from 3 to 4 by @dependabot in #2378
- Bump coursier/setup-action from 1.3.3 to 1.3.4 by @dependabot in #2424
- Bump coursier-publish from 0.1.4 to 0.1.5 by @MaciejG604 in #2433
- Bump scalajs-cli to 1.14.0 by @MaciejG604 in #2491
- Bump scala-cli-signing to 0.2.3 by @Gedochao in #2486
- Bump gcbenchmark dependencies by @Gedochao in #2481
New Contributors
- @SunKing2 made their first contribution in #2398
- @trilleplay made their first contribution in #2431
- @WojciechMazur made their first contribution in #2460
- @JD557 made their first contribution in #2484
- @doofin made their first contribution in #2458
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.0.4...v1.0.5
v1.0.4
Hotfix for buildTarget/jvmRunEnvironment in BSP
We've addressed a bug that surfaced when opening your ScalaCLI projects in Metals or IntelliJ. If you encountered the following log:
2023.08.09 15:48:34 INFO BSP server: Caused by: java.lang.IllegalArgumentException: Type ch.epfl.scala.bsp4j.JvmMainClass is instantiated reflectively but was never registered. Register the type by adding "unsafeAllocated" for the type in reflect-config.json.
2023.08.09 15:48:34 INFO BSP server: at com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets.instanceHubErrorStub(SubstrateAllocationSnippets.java:309)
2023.08.09 15:48:34 INFO BSP server: at [email protected]/sun.misc.Unsafe.allocateInstance(Unsafe.java:864)
2023.08.09 15:48:34 INFO BSP server: ... 36 more
those logs should no longer appear.
Thanks to @lwronski for providing the fix in #2342.
v1.0.3
What's new
Access project configuration with the new BuildInfo
BuildInfo
access your project's build configuration within your Scala code. This feature automatically gathers and generates build information about your project, making project details instantly accessible at runtime.
To generate BuildInfo, either use the --build-info
command line option or include the //> using buildInfo
directive in your code.
Upon activation, a BuildInfo
object becomes accessible on your project's classpath. To use it, simply add the following import into your code:
import scala.cli.build.BuildInfo
This BuildInfo
object encapsulates information such as the Scala version used, target platform, main class, scalac options, dependencies, and much more for both Main and Test scopes. The generation ensures up-to-date configuration data from both the console options and using directives in your project's sources.
Added by @MaciejG604 in #2249.
CompileOnly Dependencies
Now, users can declare dependencies that are exclusively included at the compile time. These dependencies are added to the classpath during compilation, but won't be included when the application is run, keeping your runtime environment lightweight.
To declare such a dependency:
- Via the using directive:
//> using compileOnly.dep "com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-macros:2.23.2"
- Via the command line:
scala-cli Hello.scala --compile-dep "com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-macros:2.23.2"
Added by @alexarchambault and @lwronski in #2299, Thanks!
Set globally Java properties
Scala CLI allows users to globally set Java properties for its launcher using the config
command. This will simplify the JVM properties management process, eliminating the need to pass these properties with each scala-cli
execution.
To set global Java properties execute the following command:
scala-cli config java.properties Djavax.net.ssl.trustStore=cacerts Dfoo=bar2
When modifying Java properties, remember that you must redefine all of them. It's not possible to update just a single property. Essentially, each time you use the config
command for Java properties, you replace the entire list of properties.
Whenever overwriting existing Java properties Scala CLI will let you know what was the previous value and in interactive mode ensure that you are ok with replacing them.
Added by @lwronski in #2317, Thanks!
Rename parameter for publish
command
We've updated the --version
parameter for the publish command. Now, when specifying the project version, use --project-version
instead.
scala-cli publish --project-version 1.0.3 ...
Other changes
- Add custom exception and throw it when node not found in the path by @lwronski in #2323
- Skip reading ide-options-v2.json if doesn't exist to avoid throwing a… by @lwronski in #2333
- Skip setting release flag when user pass directly -release or -java-o… by @lwronski in #2321
- Prevent downloading Java 17 when running a REPL without sources by @lwronski in #2305
- Extract JAVA_HOME from /usr/libexec/java_home for Mac by @lwronski in #2304
- Bump case-app, add names limit to HelpFormat, move some name aliases, add test by @MaciejG604 in #2280
- Build info with compute version @MaciejG604 in #2310
Fixes
- Fix - install ps, which is necessary for starting Bloop by @lwronski in #2332
- Load virtual data as byte arrays without encoding using UTF-8 by @lwronski in #2313
- Accept directive packageType native when using native platform by @lwronski in #2311
- Ignore url query params @MaciejG604 in #2334
Documentation changes
- Update runner specification by @MaciejG604 in #2301
- Add WinGet to Windows installation methods by @lwronski in #2283
- Add missing caution to Password options and fix displaying command in… by @lwronski in #2286
- Document BuildInfo @MaciejG604 in #2325
Build and internal changes
- Add timeout for resolving semanticDbVersion by @lwronski in #2322
- Resolve semanticDB for older scala version by @lwronski in #2318
- feat: use the new ScalaAction from BSP4J by @ckipp01 in #2284
Updates and maintenance
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.12 by @lwronski in #2335
- Update trees_2.13 to 4.8.7 by @scala-steward in #2329
- Update guava to 32.1.2-jre by @scala-steward in #2324
- Update bloop-rifle_2.13 to 1.5.9-sc-1 by @scala-steward in #2314
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.11 by @scala-steward in #2315
- Update scalajs-sbt-test-adapter_2.13 to 1.13.2 by @scala-steward in #2240
- Bump VirtusLab/scala-cli-setup from 1.0.1 to 1.0.2 by @dependabot in #2300
- Update mill 0.11.1 by @lwronski in #2297
- deps: update mill-scalafix to 0.3.1 by @ckipp01 in #2285
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.10 by @scala-steward in #2295
- Update sbt to 1.9.2 by @scala-steward in #2288
- Update trees_2.13 to 4.8.4 by @scala-steward in #2290
- Update scala-cli.sh launcher for 1.0.2 by @github-actions in #2281
- Update trees_2.13 to 4.8.3 by @scala-steward in #2279
- Bump semver from 5.7.1 to 5.7.2 in /website by @dependabot in #2276
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.0.2...v1.0.3
v1.0.2
What's new
This release brings enhancements to Scala CLI:
- WinGet installation for Windows users
- better navigation with improved build target names
- introducing
new
command for Giter8 project generation - easier JVM properties management with
.scalaopts
file support.
The release also includes numerous bug fixes, updates, and new contributors.
Installation via WinGet on Windows
Scala CLI can now be installed via WinGet on Windows, with a command such as
winget install virtuslab.scalacli
Added by @mimoguz in #2239, Thanks!
Enhanced build target names
Now, the build target name will be derived from the workspace directory that contains it, making it easier for users to
navigate between different projects within a multi-root workspace. Instead of a build target named as project_XYZ-XYZ
,
you will now see the name like workspace_XYZ-XYZ
, where workspace
refers to the name of the workspace directory.
.
├── scripts
│ ├── .scala-build
│ │ └── scripts_59f2159dd5
│ └ ── one.sc
├── skan
│ ├── .scala-build
│ │ └── skan_88b44a2858
│ └── main.scala
└── skan.code-workspace
Added by @MaciejG604 in #2201
Introducing 'new' command for Giter8 project generation
Giter8 is a project templating tool for Scala, and its integration within Scala CLI offers efficient way to set up new
projects. By using the new
command, users can generate new projects based on predefined or custom templates.
For example:
scala-cli --power new VirtusLab/scala-cli.g8
Added by @zetashift in #2202, Thanks!
Loading Java Properties from .scalaopts
into ScalaCLI launcher
ScalaCLI allows to load Java properties into scala-cli
launcher directly from a .scalaopts
file located in your
current working directory. This will simplify the JVM properties management process, eliminating the need to pass these
properties with each scala-cli execution.
For instance, if -Djavax.net.ssl.trustStore=cacerts
and -Dfoo2=bar2
are defined within your .scalaopts
file, these
values will be loaded into scala-cli
launcher:
$ cat .scalaopts
-Djavax.net.ssl.trustStore=cacerts
-Dfoo2=bar2
$ scala-cli run ...
Please be aware that ScalaCLI will only process Java properties that it recognizes from the .scalaopts
file. Other JVM
options, such as -Xms1024m
, will be ignored as they can't be used within native image, and users will be alerted with
a warning message when such non-compliant options are passed.
Other changes
- Add publish.doc directive by @lwronski in #2245
- Fix pgp create with no java 17 by @MaciejG604 in #2189
- Support for running standalone launcher of scala-cli with JVM 8 by @lwronski in #2253
Fixes
- Make dependencies keep their positions when fetching by @MaciejG604 in #2266
- Fix empty position in DependencyFormatErrors by @MaciejG604 in #2261
- Script wrapper verification by @MaciejG604 in #2227
- Fix - include test.resourceDir into sources for test scope by @lwronski in #2235
- Fix markdown - allow running .md files that start with a number by @lwronski in #2225
- Fix dep update error by @MaciejG604 in #2211
- Add new mechanism for resolving scoped BuildOptions by @MaciejG604 in #2274
- Fix - download cs from coursier-m1 as an archive by @lwronski in #2193
- Fix - Truncate file length to 0 when override content by @lwronski in #2188
Documentation changes
- Add mentions that using target directives are experimental by @MaciejG604 in #2262
- Fix inline code in directives docs by @izzyreal in #2233
- Update docs - dependency parameters by @lwronski in #2224
- Update directive docs for Platform by @lwronski in #2213
Build and internal changes
- Build changes by @lwronski in #2263
- Remove file change portion of test by @MaciejG604 in #2251
- Add logging to 'watch with interactive' test by @MaciejG604 in #2229
- Add support for parsing cancel params in native launcher of Scala CLI by @lwronski in #2195
Updates and maintenance
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.7 by @scala-steward in #2271
- Update trees_2.13 to 4.8.2 by @scala-steward in #2272
- Update core_2.13 to 3.8.16 by @scala-steward in #2270
- Update jimfs to 1.3.0 by @scala-steward in #2269
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.6 by @scala-steward in #2264
- Update trees_2.13 to 4.8.1 by @scala-steward in #2265
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.5 by @scala-steward in #2256
- Update trees_2.13 to 4.8.0 by @scala-steward in #2257
- Update guava to 32.1.1-jre by @scala-steward in #2259
- Update coursier-jvm_2.13, ... to 2.1.5 by @scala-steward in #2232
- Update sbt to 1.9.0 by @scala-steward in #2222
- Update dependency to 0.2.3 by @scala-steward in #2219
- Update org.eclipse.jgit to 6.6.0.202305301015-r by @scala-steward in #2220
- Updates -
amm
(2.5.9
),scala-library
(2.12.18
,2.13.11
) by @lwronski in #2223 - Update bsp4j to 2.1.0-M5 by @scala-steward in #2216
- Update jsoniter-scala-core, ... to 2.23.2 by @scala-steward in #2217
- Update scala-collection-compat to 2.11.0 by @scala-steward in #2221
- Update test-runner, tools to 0.4.14 by @scala-steward in #2192
- Bump VirtusLab/scala-cli-setup from 1.0.0 to 1.0.1 by @dependabot in #2207
- Update guava to 32.0.1-jre by @scala-steward in #2197
- Update scala-cli.sh launcher for 1.0.1 by @github-actions in #2194
- Upgrade scripts to latest coursier by @mkurz in #1728
New Contributors
- @zetashift made their first contribution in #2202
- @izzyreal made their first contribution in #2233
- @mimoguz made their first contribution in #2239
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.0.1...v1.0.2
v1.0.1
What's new
This release only contains bug fixes and minor internal improvements.
Fixes
- Fix - add test to output from name of script example by @lwronski in #2153
- Fix publishing with implicit
publish.version
coming from agit
tag by @Gedochao in #2154 - Fix conflicts when watch and interactive try to read StdIn by @MaciejG604 in #2168
- Bsp wrapper fixes by @MaciejG604 in #2171
- Add the .exe suffix to output provided by user for graalvm-native-image by @lwronski in #2182
Build and internal changes
- refactor: Remove JavaInterface, which causes compilation issues with Bloop by @tgodzik in #2174
- Enforce to use jvm 17 on linux aarch64 by @lwronski in #2180
Updates and maintenance
- Update scala-cli.sh launcher for 1.0.0 by @github-actions in #2149
- Back port of documentation changes to main by @github-actions in #2155
- Update jsoniter-scala-core, ... to 2.23.1 by @scala-steward in #2160
- Update guava to 32.0.0-jre by @scala-steward in #2161
- Update coursier-jvm_2.13, ... to 2.1.4 by @scala-steward in #2162
- Update sbt to 1.8.3 by @scala-steward in #2164
- Bump
mill
scripts by @Gedochao in #2167 - Bump VirtusLab/scala-cli-setup from 0.2.1 to 1.0.0 by @dependabot in #2169
- Bump
scala-cli-signing
to0.2.2
by @Gedochao in #2173 - Update scalafmt-cli_2.13, scalafmt-core to 3.7.4 by @scala-steward in #2175
- Update trees_2.13 to 4.7.8 by @scala-steward in #2176
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.0.0...v1.0.1
v1.0.0
The official scala
runner release
Scala CLI has reached the highly anticipated 1.0.0
milestone!
Having addressed all the SIP-46 requirements,
this version is going to become the official scala
runner, replacing the old scala
command.
For a deeper understanding of Scala CLI as the new scala
runner and to explore its benefits and features,
we encourage you to check out our blogpost.
Also be sure to get familiar with all the differences introduced by this change in our migration guide.
What's Changed
New default Scala version - 3.3.0
Scala 3.3.0 is now the default version for Scala CLI projects. It's the first LTS (Long Term Support) release of Scala 3 to be used by Scala CLI. Right on time for 1.0.0!
Toolkit-test
By incorporating the Scala Toolkit into your project, you gain the advantage of two additional dependencies seamlessly integrated into your classpath:
org.scala-lang:toolkit:<version>
is added to the main scope, allowing its utilization throughout your project.org.scala-lang:toolkit-test:<version>
is included in the test scope, making it available exclusively for testing purposes.
Scala CLI now supports the following features for the toolkit:
- including e.g.
//> using toolkit latest
in any main scope file will automatically add thetoolkit
dependency to the main scope and thetoolkit-test
dependency to the test scope - if you place e.g.
//> using toolkit latest
within a test scope file, bothtoolkit
andtoolkit-test
will be limited to the test scope only - inserting e.g.
//> using test.toolkit latest
anywhere in the project will add bothtoolkit
andtoolkit-test
to the test scope only
This convention is encouraged for other toolkit-like libraries as well.
Added by @Gedochao in #2127 and #2137
Forcing an object wrapper for scripts
Scala CLI now supports the //> using objectWrapper
directive, along with the corresponding --object-wrapper
option,
which allows to force wrapping script code in an object body instead of a class.
Using object wrappers should be avoided for scripts relying on multi-threading (as it may cause deadlocks), but may prove to be the only option in some cases.
Added by @MaciejG604 in #2136
Other changes
- Add alias for snapshots repository in Maven by @lwronski in #2125
- Bump typelevel-toolkit to 0.0.11, configure toolkit-test by @armanbilge in #2135
- Fix updating toolkit dependencies by @Gedochao in #2138
- Improve directive parsing errors & special-case
toolkit
directive version parsing by @Gedochao in #2133 - Fix determining position for value in directive without quotes by @lwronski in #2141
Fixes
- Fix line conversion logic by simplifying topWrapperLen to line count of top wrapper by @MaciejG604 in #2101
- Fix test watch infinite loop by @MaciejG604 in #2113
- Fix flaky completions for
zsh
by @Jasper-M in #2118 - Fix - install certificates for java by @lwronski in #2123
- Fix the
--source-jar
option & add correspondingusing
directives by @Gedochao in #2120
Documentation changes
- Add docs for bootstrapped standalone fat JAR by @lwronski in #2122
- Add developer docs on modifying
reflect-config.json
by @Gedochao in #2114
Build and internal changes
- Update release procedure - update also v1 tag by @lwronski in #2107
- NIT Refactor test scope directives by @Gedochao in #2083
- Add main class to jar manifest in assembly by @romanowski in #2124
Updates and maintenance
- Update scala-cli.sh launcher for 1.0.0-RC2 by @github-actions in #2105
- Update org.eclipse.jgit to 6.5.0.202303070854-r by @scala-steward in #2090
New Contributors
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.0.0-RC2...v1.0.0
v1.0.0-RC2
What's Changed
Exclude
To exclude specific source files or entire directories from a Scala CLI project, you can now use the //> using exclude
directive in your project.scala
file.
Alternatively, you can do the same from the command line with the --exclude
option.
- absolute path:
/root/path/to/your/project/Main.scala
- relative path:
src/main/scala/Main.scala
- glob pattern:
*.sc
For example, to exclude all files in the example/scala
directory, add the following directive to your project.scala
file:
//> using exclude "example/scala"
Directives with a Test Scope equivalent
Some directives now have a test scope equivalent, such as using dep
and its test scope counterpart using test.dep
. This allows you to declare dependencies that are only used in tests outside of test-specific sources.
For example, you can declare a dependency on munit
in your project.scala
file like this:
//> using test.dep "org.scalameta::munit::0.7.29"
The dependency will only be available in test sources.
Here's a list of directives with a test scope equivalent with example values:
//> using test.dep "org.scalameta::munit::0.7.29"
//> using test.jar "path/to/jar"
//> using test.javaOpt "-Dfoo=bar"
//> using test.javacOpt "source", "1.8", "target", "1.8"
//> using test.javaProp "foo1=bar1"
//> using test.option "-Xfatal-warnings"
//> using test.resourceDir "testResources"
//> using test.toolkit "latest"
Changes to using-directives syntax
We've made several updates to simplify the using directives syntax in this release:
- allowed omitting commas in lists of values.
- disallowed multiline comments.
- removed multiline strings.
- removed
require
and@require
syntax support. - allowed values without quotes.
- removed
@using
.
For example, the following using directives are now valid without the need for commas and quotes:
//> using scala 3.2.2
//> using javacOpt -source 1.8 -target 1.8
Bootstrapped standalone fat JAR.
The Scala CLI launcher is available as a standalone fat JAR. You can download the stable version of the Scala CLI fat JAR from Maven and try it now:
cs launch org.virtuslab.scala-cli:cliBootstrapped:1.0.0-RC2 -M scala.cli.ScalaCli
Added by @romanowski in #2005.
Access the path of the script being run from its code
With the special scriptPath
function, you can now easily access the path of the script being run from the script code itself.
Here's an example of how to use the scriptPath
value:
#!/usr/bin/env -S scala-cli shebang
println(scriptPath)
chmod +x scripts/hello.sc
./scripts/hello.sc
./scripts/hello.sc
Explicit Handling of Paths in using-directives
The ${.}
pattern in directive values can now be replaced by the parent directory of the file containing the directive. This makes it possible to generate coverage output files relative to the source file location, for example:
//> using options "-coverage-out:${.}"
Fix deadlocks in Script Wrappers
We have resolved an issue that caused deadlocks when threads were run from the static initializer of the wrapper object (#532 and #1933). Based on the feedback from the community (Thanks @dacr), we found that encapsulating the script code into a class wrapper fixes the issue. The wrapper is generated by the Scala CLI and is not visible to the user.
This change alters the behavior of scripts that use the @main
annotation. The @main
annotation is no longer supported in .sc
files.
@main def main(args: String*): Unit = println("Hello")
scala-cli script.sc
[warn] Annotation @main in .sc scripts is not supported, use .scala format instead
Compiling project (Scala 3.2.2, JVM)
[error] ./script.sc:1:1
[error] method main cannot be a main method since it cannot be accessed statically
[error] @main def main(args: String*): Unit = println("Hello")
[error] ^^^^^
Error compiling project (Scala 3.2.2, JVM)
Compilation failed
Fixed by @MaciejG604 in #2033
Other changes
- Add first-class support for Typelevel and other toolkits by @armanbilge in #2025
- Make shebang run not check dependency updates by @MaciejG604 in #2022
- Make 'export --json' print to stdout by default by @MaciejG604 in #2008
- Don't print the spread directives warning if there's only a single file per scope by @Gedochao in #1988
- Add --as-jar option by @alexarchambault in #2028
- add newline to topWrapper by @bishabosha in #1998
Publishing changes
- React to secret key decryption error by @MaciejG604 in #1993
- Use ASCII armored secret key by @MaciejG604 in #1991
- Properly handle pgp keychains generated by Scala CLI by @MaciejG604 in #1987
Fixes
- Fix
ExcludeTests
by @Gedochao in #2082 - bugfix: Properly show unsupported binary version by @tgodzik in #2081
- Allow BSP to start successfully even with unrecognised
using
directives by @Gedochao in #2072 - Fix invalid
scala-cli-signing
artifact downloads by @Gedochao in #2054 - Fix - package js without main method by @lwronski in #2038
- Fix completions by @Gedochao in #2004
- Fix export failing on input duplicates @Gedochao in #2098
- Clean up parsing repositories for publishing @romanowski in #2084
Documentation changes
- Docs: Update build output folder in Internal docs by @amaalali in #2071
- Add docs for test scope directives by @Gedochao in #2058
- Improve error messages for malformed
config
values by @Gedochao in #2014 - Update export documentation by @MaciejG604 in #2023
- Add weaver test framework instruction by @lenguyenthanh in #2021
Build and internal changes
- Download cs for aarch64 from coursier-m1 repo by @lwronski in #2085
- Pass
invokeData
all the way to pre-processing to give more meaningful error/warning messages by @Gedochao in #2073 - Refactor
using
directives processing by @Gedochao in #2066 - Remove the
examples
directory to fixscala-steward
runs by @Gedochao in #2067 - Remove some dead code in build by @alexarchambault in #2069
- NIT Remove dead
BuildDeps
by @Gedochao in #2065 - Clean up build by @romanowski in #2017
- Developers reflect 5 active developers in the repo. by @romanowski in #2006
- Increase maximum memory allocation for JVM by @lwronski in #2012
- Use bloop-rifle module from scala-cli/bloop-core repo by @alexarchambault in #1989
- Add missing modules for which unit tests are now executed by @lwronski in #1992
- Remove dead code for ordering PreprocessedSources by @MaciejG604 in #2103
Updates and maintenance
- Downgrade GraalVM to
22.3.1
to fix M1 by @Gedochao in #2099 - Update slf4j-nop to 2.0.7 by @scala-steward in #2095
- Update sbt to 1.6.2 by @scala-steward in #2093
- Update bsp4j to 2.1.0-M4 by @scala-steward in #2086
- Bump
coursier
to2.1.3
by @Gedochao in #2077 - Update core_2.13 to 3.8.15 by @scala-steward in #2087
- Update file-tree-views to 2.1.10 by @scala-steward in #2088
- Bump
graalvm
to22.3.2
by @Gedochao in #2078 - Update asm to 9.5 by @scala-steward in #2092
- Bump coursier/setup-action from 1.3.2 to 1.3.3 by @dependabot in #2070
- Bump
jsoniter
,scalameta
,os-lib
andscala-collection-compat
by @Gedochao in #2064 - Bump
coursier
to2.1.2
by @Gedochao in #2063 - Bump
ammonite
to2.5.8
by @Gedochao in #2057 - Bump Scala.js to
1.13.1
by @Gedochao in #2062 - Bump coursier/setup-action from 1.3.1 to 1.3.2 by @dependabot in #2055
- Bump coursier/setup-action from 1.3.0 to 1.3.1 by @dependabot in #2042
- Dump bloop core to 1.5.6-sc-8 by @lwronski in #2013
- Fix snapshot versions calculation when the current version ends with
-RC.
by @Gedochao in #2002 - Update scala-cli.sh launcher for 1.0.0-RC1 by @github-actions in #1995
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.3 by @scala-steward in #2094
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v1.0.0-RC1...v1.0.0-RC2
v1.0.0-RC1
Official scala
runner release candidate
v1.0.0-RC1
is the first release candidate version of Scala CLI.
Either this or a future release candidate is meant to become the new official scala
runner to accompany
the Scala compiler (scalac
) and other scripts, replacing the old scala
command.
To learn more about Scala CLI as the new scala
runner, check out our recent blogpost:
https://virtuslab.com/blog/scala-cli-the-new-scala-runner/
Scala CLI should now have better performance
With a number of newly added performance tweaks, you can expect Scala CLI to run considerably faster. Added by @lwronski in #1939
Print appropriate warnings when experimental features are used
Using experimental features will now cause Scala CLI to print an appropriate warning.
scala-cli --power -e '//> using publish.name "my-library"'
# The '//> publish.name "my-library"' directive is an experimental feature.
# Please bear in mind that non-ideal user experience should be expected.
# If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli
The warning can be suppressed with the --suppress-experimental-warning
option, or alternatively with the
suppress-warning.experimental-features
global config key.
scala-cli config suppress-warning.experimental-features true
Experimental and restricted configuration keys will now require to be accessed in --power
mode
Some configuration keys available with the config
sub-command have been tagged as experimental or restricted and will
only be available in --power
mode.
scala-cli config httpProxy.address
# The 'httpProxy.address' configuration key is restricted.
# You can run it with the '--power' flag or turn power mode on globally by running:
# scala-cli config power true
Dropped deprecated using
directive syntax
The following syntax for using
directives have been dropped:
- skipping
//>
- multiline directives
- directives in
/*> ... */
comments - directives in plain
//
comments @using
Added support for packaging native images from Docker
It is now possible to package a GraalVM native image with Scala CLI from docker.
docker run -v $(pwd)/Hello.scala:/Hello.scala virtuslab/scala-cli package --native-image /Hello.scala
Added support for Scala Native's LTO
It is now possible to set the Link Time Optimization (LTO) when using Scala CLI with Scala Native.
The available options are "thin", "full" and "none".
You can do it with the --native-lto
option from the command line:
scala-cli -e 'println("Hello")' --native --native-lto thin
Or with a using
directive:
//> using platform "scala-native"
//> using nativeLto "thin"
@main def main(): Unit = println("Hello")
Other changes
Publishing changes
- Make credential entries respect the --password-value option by @MaciejG604 in #1949
- Write PGP keys to publish-conf when doing publish setup by @MaciejG604 in #1940
- Comply with optional password in
scala-cli-signing
by @MaciejG604 in #1982 - Support ssh in GitHub repo org&name extraction by @KuceraMartin in #1938
Fixes
- Print an informative error if the project workspace path contains
File.pathSeparator
by @Gedochao in #1985 - Enable to pass custom docker-cmd to execute application in docker by @lwronski in #1980
- Fix - uses show cli.nativeImage command to generate native image by @lwronski in #1975
- Vcs.parse fix by @KuceraMartin in #1963
- move args definition to the top of the script by @bishabosha in #1983
Documentation changes
- Back port of documentation changes to main by @github-actions in #1935
- Remove ChainedSnippets by @MaciejG604 in #1928
- Further document publish command by @MaciejG604 in #1914
- Add a verbosity guide by @Gedochao in #1936
- Docs - how to run unit tests in Scala CLI by @lwronski in #1977
Build and internal changes
- Use locally build jvm launcher of scala-cli in gifs generator by @lwronski in #1921
- Clean up after ammonite imports removal by @MaciejG604 in #1934
- Temporarily disable
PublishTests.secret keys in config
on Windows by @Gedochao in #1948 - Move toolkit to scalalang org by @szymon-rd in #1930
Updates and maintenance
- Update scala-cli.sh launcher for 0.2.1 by @github-actions in #1931
- Bump VirtusLab/scala-cli-setup from 0.2.0 to 0.2.1 by @dependabot in #1947
- Bump coursier/publish version to 0.1.4 by @MaciejG604 in #1950
- Bump to the latest weaver & remove expecty by @lenguyenthanh in #1955
- Bump webfactory/ssh-agent from 0.7.0 to 0.8.0 by @dependabot in #1967
- chore(dep): bump mill from 0.10.10 to 0.10.12 by @ckipp01 in #1970
- Bump Bleep to
1.5.6-sc-4
by @Gedochao in #1973
New Contributors
- @KuceraMartin made their first contribution in #1938
- @lenguyenthanh made their first contribution in #1955
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.2.1...v1.0.0-RC1
v0.2.1
Add a guide for migrating from the old scala
runner to Scala CLI
As of SIP-46, Scala CLI has been accepted as the new scala
command. To make the transition smooth we added a guide highlighting
the differences between the two runners.
Improve the publish
and publish setup
sub-commands' user experience
We're currently focusing on improving the experimental publish
feature of Scala CLI and making publish setup
+ publish
more stable and user-friendly.
Using pgp keys created by config --create-pgp-key
subcommand is now supported as a default option,
no additional user input is needed.
Addressed by @alexarchambault in #1432 and by @MaciejG604 in #1898
Remove unsupported kebab-case style in using directives
All using directives names are now using camelCase, kebab-case is no longer available.
Add a reference for available config keys in help & docs
You can now view the available config keys using config --help
:
scala-cli config -h
# Usage: scala-cli config [options]
# Configure global settings for Scala CLI.
#
# Available keys:
# actions Globally enables actionable diagnostics. Enabled by default.
# interactive Globally enables interactive mode (the '--interactive' flag).
# power Globally enables power mode (the '--power' launcher flag).
# suppress-warning.directives-in-multiple-files Globally suppresses warnings about directives declared in multiple source files.
# suppress-warning.outdated-dependencies-files Globally suppresses warnings about outdated dependencies.
#
# You are currently viewing the basic help for the config sub-command. You can view the full help by running:
# scala-cli config --help-full
# For detailed documentation refer to our website: https://scala-cli.virtuslab.org/docs/commands/misc/config
#
# Config options:
# --unset, --remove Remove an entry from config
Also, config --full-help
will show the list of all keys.
Pass user arguments to JS runner
It's now possible to pass user arguments to a JS application:
import scala.scalajs.js
import scala.scalajs.js.Dynamic.global
val process = global.require("process")
val argv = Option(process.argv)
.filterNot(js.isUndefined)
.map(_.asInstanceOf[js.Array[String]].drop(2).toSeq)
.getOrElse(Nil)
val console = global.console
console.log(argv.mkString(" "))
scala-cli ScalaJsArgs.sc --js -- Hello World
Hello World
Added by @alexarchambault in #1826
Other changes
- Tweak error messages for running scripts without file extensions by @Gedochao in #1886
- Exit with Bloop command return code if it's non-zero by @alexarchambault in #1837
- bloop-rifle: increase timeout values by @Flowdalic in #1865
- Suggest users to clean working directory when Nailgun server failed by @lwronski in #1916
- fix: encode videos in yuv420p to support Firefox by @danielleontiev in #1904
- Fix reading passwords from commands by @alexarchambault in #1775
- Add extra class path to generated bootstrap launcher by @lwronski in #1897
SIP-related changes
- Add 'dependency' and 'dependencies' alias for using directive by @MaciejG604 in #1903
Documentation updates
- Ensure no console-syntax in reference docs and no
md
fenced blocks in--help
by @Gedochao in #1874 - Document export subcommand by @MaciejG604 in #1875
- Tweak guides' and cookbooks' pages by @Gedochao in #1894
- Fix pgp creation option name by @MaciejG604 in #1909
- Fix using directive docs by @lwronski in #1901
- Add docs to classifiers and exclude dependency by @lwronski in #1892
Internal changes
- Fix handling for
experimental
features by @Gedochao in #1915 - Change default home directory for tests integration and docs-test modules to avoid overriding global user config by @lwronski in #1917
- NIT Use enums for help groups and help command groups by @Gedochao in #1880
Updates & maintenance
- Bump dns-packet from 5.3.1 to 5.4.0 in /website by @dependabot in #1906
- Bump VirtusLab/scala-cli-setup from 0.1.20 to 0.2.0 by @dependabot in #1890
- Dump docusaurus to 2.3.1 and other docs deps by @lwronski in #1907
- Update scala-cli.sh launcher for 0.2.0 by @github-actions in #1881
- Back port of documentation changes to main by @github-actions in #1911
New Contributors
- @danielleontiev made their first contribution in #1904
v0.2.0
Require the --power
option for restricted features by default
Until now, Scala CLI has been limiting some of its functionalities in its scala
distribution.
Starting with v0.2.0
, those limitation will be applied to all distributions, including scala-cli
.
This was done in order to make the behaviour consistent with Scala CLI acting as the Scala runner.
Restricted features can be accessed by using the --power
launcher flag. Do note that launcher flags have to be passed before the sub-command.
scala-cli --power package .
Alternatively, the power
mode can be turned on globally by running:
scala-cli config power true
Please note that this change may affect your existing scripts or workflows that rely on the limited commands from ScalaCLI (such as package
, publish
). You can still use those commands with power
mode enabled.
When you try to use a limited command in restricted mode, you will now see a warning message with suggestions on how to enable this command:
$ scala-cli package Hello.scala
# This command is restricted and requires setting the `--power` option to be used.
# You can pass it explicitly or set it globally by running:
# scala-cli config power true
$ scala-cli config power true
$ scala-cli package Hello.scala
# Wrote Hello, run it with
# ./Hello
Added by @lwronski in #1835 and #1849
Allow executable Scala scripts without a file extension
As of this release Scala scripts without the *.sc
file extension will be supported for execution when using the shebang
command.
#!/usr/bin/env -S scala-cli shebang -S 3
println(args.size)
println(args.headOption)
chmod +x hello
./hello Hello World
#2
#Some(Hello)
Note that files with no extension are always run as scripts even though they may contain e.g. a valid .scala
program.
Also, do note that this feature has only been added for shebang
- the run
sub-command (which is the default way of running inputs when a sub-command is not specified explicitly) will not support this.
Added by @MaciejG604 in #1802
Export Project configuration to Json
It is now possible to export configuration from Scala CLI project to Json format with the export
sub-command.
scala-cli --power export --json .
It is currently exporting basic information about the project and includes, for example, the following fields:
- ScalaVersion
- Platform
- Sources
- Dependencies
- Resolvers
Example of generated Json output:
{
"scalaVersion": "3.2.2",
"platform": "JVM",
"scopes": {
"main": {
"sources": [
"Hello.scala"
],
"dependencies": [
{
"groupId": "com.lihaoyi",
"artifactId": {
"name": "pprint",
"fullName": "pprint_3"
},
"version": "0.6.6"
}
],
...
}
}
}
Added by @MaciejG604 in #1840
Rename using lib
to using dep
To be more consistent with dependency command line options --dep
, the dependency using directive is now passed by using dep
.
Please note that we have kept the alias of the old directive (lib
, libs
) for backwards compatibility.
//> using dep "org.scalameta::munit:0.7.29"
Other breaking changes
Remove ammonite imports support
The support for $ivy
and $dep
ammonite imports has been removed.
To easily convert existing $ivy
and $dep
imports into the using dep
directive in your sources, you can use the provided actionable diagnostic.
Removed by @MaciejG604 in #1787
Drop the metabrowse
sub-command
With this release, support for Metabrowse has been removed from Scala CLI. This change was made in order to limit the number of features that we need to support, especially since the Metabrowse
project is no longer being actively worked on.
Other changes
- Add cross-platform toolkit dependency by @bishabosha in #1810
- Show explain message when is enabled by @lwronski in #1830
- Read home directory from env variable instead of option from command line by @lwronski in #1842
- Add build/taskStart and taskFinish to the exception reporting BSP mechanism by @MaciejG604 in #1821
- blooprifle: report exit code in exception by @Flowdalic in #1844
- Suppress lib update warning by @MaciejG604 in #1848
- Invalid subcommand arg by @MaciejG604 in #1811
SIP-related changes
- Add a warning for the
-run
option of the legacyscala
runner, instead of failing by @Gedochao in #1801 - Add warnings for the deprecated
-Yscriptrunner
legacyscala
runner option instead of passing it toscalac
by @Gedochao in #1804 - Filter out
restricted
&experimental
options fromSIP
mode help by @Gedochao in #1812 - Warn in sip mode when using restricted command by @lwronski in #1862
- Add more detail for sub-commands' help messages by @Gedochao in #1852
- Fix printing not supported option in restricted mode by @lwronski in #1861
- Shorter options help by @Gedochao in #1872
Fixes
- Fix warning about using directives in multiple files when two java files are present by @MaciejG604 in #1796
- Quit flag not suppresses compilation errors by @lwronski in #1792
- Dont warn about target directives by @MaciejG604 in #1803
- Fix - actionable actions not suggest update to previous version by @lwronski in #1813
- Fix actionable action when uses latest sytanx version in lib by @lwronski in #1817
- Prevent NPE from being thrown by the
export
sub-command iftestFramework
isn't defined by @Gedochao in #1814 - Fix message checking in test by @MaciejG604 in #1847
- blooprifle: add -XX:+IgnoreUnrecognizedVMOptions to hardCodedDefaultJavaOpts by @Flowdalic in #1845
- Trim passwords obtained as command result by @MaciejG604 in #1871
Build and internal changes
- Ignore Bloop server early exit if it signals an already running server by @alexarchambault in #1799
- Build aarch64 linux launcher using m1 by @lwronski in #1805
- Remove latest supported scala version mechanism by @lwronski in #1816
- Switch
scala-cli-signing
toorg.virtuslab
and bump to0.1.15
by @Gedochao in #1853 - Add clang to scala-cli docker image by @lwronski in #1846
- bloop-file: show timeout value in error message by @Flowdalic in #1855
- Back port of documentation changes to main by @github-actions in #1860
- Run generate reference doc as non sip by @lwronski in #1866
- Bump
case-app
to2.1.0-M23
by @lwronski in #1868
Documentation updates
- Update docker example command by @MaciejG604 in #1798
- Tweak
--watch
/--restart
disambiguation in the help messages & docs by @Gedochao in #1819 - Release notes - msi malware analysis by @lwronski in #1832
- Improve 'shebang' help message wrt program arguments by @Flowdalic in #1829
- docs: Fix Yum manual installation step by @tgodzik in #1850
Updates & maintenance
- Update scala-cli.sh launcher for 0.1.20 by @github-actions in #1790
- Bump VirtusLab/scala-cli-setup from 0.1.19 to 0.1.20 by @dependabot in #1806
New Contributors
- @Flowdalic made their first contribution in #1829
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.20...v0.2.0
v0.1.20
Add support for Scala Toolkit
Scala CLI now has support for Scala Toolkit.
Scala Toolkit is an ongoing effort by Scala Center and VirtusLab to compose a set of approachable libraries to solve everyday problems.
It is currently in its pre-release phase and includes the following libraries:
- MUnit for testing;
- Sttp for HTTP client;
- UPickle/UJson for reading, writing and operating on JSONs;
- OS-Lib for operating on files and the operating system.
You can add it to your Scala CLI build from the command line with the --with-toolkit
option.
scala-cli . --with-toolkit latest
There's also an appropriate using
directive.
//> using toolkit "0.1.6"
Scala CLI is built with Scala 3.2.2
We now rely on Scala 3.2.2
as the default internal Scala version used to build the project.
Added by @lwronski and @Gedochao in #1772
Removal of the about
and doctor
sub-commands
The about
command has been removed, its features merged back to the version
command.
As a result, the version
command will now check if your locally installed Scala CLI is up-to-date.
It is possible to skip the check with the --offline
option, or when printing raw CLI or default Scala
versions with --cli-version
and --scala-version
, respectively.
scala-cli version --offline
# Scala CLI version: 0.1.20
# Scala version (default): 3.2.2
Similarly, the doctor
sub-command has been removed, with its past and previously planned functionalities to be delivered
in a more interactive manner in the future.
The Scala CLI aarch64/arm64
binary is now available via sdkman
You can now get the platform-appropriate Scala CLI binary on aarch64/arm64
architecture via sdkman
.
aarch64/arm64
artifact with the launcher script
The scala-cli.sh
launcher script now correctly downloads the aarch64/arm64
artifact on the appropriate architecture.
Run a .jar
file as a regular input
JARs can now be run just like any other input, without the need of passing the -cp
option.
scala-cli Hello.jar
# Hello
Java properties without the need for --java-prop
The --java-prop
option can be skipped when passing Java properties to Scala CLI now.
scala-cli Hello.scala -Dfoo=bar
Docker packaging with using
directives
It is now possible to configure packaging into a docker image via using
directives.
//> using packaging.dockerFrom "openjdk:11"
//> using packaging.dockerImageTag "1.0.0"
//> using packaging.dockerImageRegistry "virtuslab"
//> using packaging.dockerImageRepository "scala-cli"
Pass GraalVM args via a using
directive
It is now possible to pass args to GraalVM via the following using
directive:
//> using packaging.graalvmArgs "--no-fallback", "--enable-url-protocols=http,https"
Other changes
SIP-related changes
- Remove irrelevant options from
version
help message by @lwronski in #1737 - Include launcher options in the help for the default and
help
sub-commands by @Gedochao in #1725 - Remove suffix
.aux
from progName when installed by cs by @lwronski in #1736 - Don't fail in case of connection errors in the version sub-command by @Gedochao in #1760
- Set workspace dir to
os.tmp.dir
for virtual sources by @lwronski in #1771 - Add support for deprecated Scala
2.13.x
-specificscala
runner options by @Gedochao in #1774 - Add support for the
-with-compiler
runner option by @Gedochao in #1780
Fixes
- Take into account interactively picked options when caching binaries by @alexarchambault in #1701
- Erase things in working dir in publish by @alexarchambault in #1715
- Improve formatting of generated Mill project by @lolgab in #1677
- Restart Bloop server if it exited by @alexarchambault in #1716
- Add a global configuration for suppressing the warning about directives in multiple files by @MaciejG604 in #1779
- Add CLI option for suppressing the warning about directives in multiple files by @MaciejG604 in #1754
- Set page size for aarch64 Linux binaries to 64k by @mkurz in #1726
Build and internal changes
- Tweaking by @alexarchambault in #1711
- Address some native-image warnings by @alexarchambault in #1719
- Do not generate Linux aarch64 binaries from PRs by @alexarchambault in #1720
- Derive using directives handlers from case classes by @alexarchambault in #1637
- Don't run commands upon HelpTests instantiation by @alexarchambault in #1762
Documentation updates
- Add test-only cookbook by @lwronski in #1718
- Fixing minor typos and some wordsmithing. by @medale in #1731
- Back port of documentation changes to main by @github-actions in #1735
- Explain the differences in using shebang vs scala-cli directly in script by @lwronski in #1740
- Add instruction for Intellij JVM version by @MaciejG604 in #1773
- Fix a broken link by @xerial and @lwronski in #1777
Updates & maintenance
- Update svm to 22.3.0 by @scala-steward in #1689
- Update scala-cli.sh launcher for 0.1.19 by @github-actions in #1707
- Bump VirtusLab/scala-cli-setup from 0.1.18 to 0.1.19 by @dependabot in #1709
- Update Bloop to 1.5.6-sc-1 by @lwronski in #1704
- Update trees_2.13 to 4.7.1 by @scala-steward in #1717
- Update coursier-jvm_2.13, ... to 2.1.0-RC4 by @scala-steward in #1723
- Bump uraimo/run-on-arch-action from 2.3.0 to 2.5.0 by @dependabot in #1734
- Update jsoniter-scala-core_2.13, ... to 2.20.0 by @scala-steward in #1732
- Update jsoniter-scala-core_2.13, ... to 2.20.1 by @scala-steward in #1741
- Update scalafmt-cli_2.13, scalafmt-core to 3.6.1 by @scala-steward in #1742
- Update core_2.13 to 3.8.6 by @scala-steward in #1746
- Update libdaemon to 0.0.11 by @scala-steward in #1759
- Update jsoniter-scala-core_2.13, ... to 2.20.2 by @scala-steward in #1757
- Update core_2.13 to 3.8.7 by @scala-steward in #1758
- Update bloop core to 1.5.6-sc-2 by @lwronski in #1761
- Update core_2.13 to 3.8.8 by @scala-steward in #1770
- Update ammonite to 2.5.6 by @scala-steward in #1769
- Update jsoniter-scala-core_2.13, ... to 2.20.3 by @scala-steward in #1776
- Update amm to 2.5.6-1-f8bff243 by @lwronski in #1778
New Contributors
- @mkurz made their first contribution in #1726
- @medale made their first contribution in #1731
- @MaciejG604 made their first contribution in #1773
- @xerial made their first contribution in #1777
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.19...v0.1.20
v0.1.19
The Linux aarch64
native launcher is here! (experimental)
We are happy to announce that there is a new dedicated launcher for the Linux Aarch64. You can find it here.
Fix workspace/reload
for Intellij IDEA
Dependencies (and other configurations) from using
directives should now always be picked up after a BSP project reload.
shebang
headers in Markdown
The shebang
headers in scala
code blocks inside a markdown input are always ignored.
# Scala with `shebang`
A sample code block with the `shebang` header.
```scala
#!/usr/bin/env -S scala-cli shebang
println("Hello world")
```
Export Scala compiler plugins to Mill projects
It is now possible to export scalac
compiler plugins from a Scala CLI project to Mill with the export
sub-command.
Added by @carlosedp in #1626
Other changes
SIP Changes
- Fix the order of help command groups for the default help by @Gedochao in #1697
- Adjust SIP help output & ensure
ScalaSipTests
are run on Windows by @Gedochao in #1695 - Add warnings for
-save
&-nosave
legacyscala
runner options instead of failing by @Gedochao in #1679
Fixes
- Suggest to update only to stable version by @lwronski in #1634
- Fix - Skip checking file order by @lwronski in #1696
- fix if else in mill.bat by @MFujarewicz in #1661
- Add repositories from build options when validating scala versions by @lwronski in #1630
- Fix using directives not working with the shebang line in
.scala
files by @Gedochao in #1639 - Don't clear compilation output dir by @clutroth in #1660
Documentation updates
- Decompose the README & add a contributing guide by @Gedochao in #1650
- Improve IDE support docs by @Gedochao in #1684
Build and internal changes
- Use snapshot repo to download stubs by @lwronski in #1693
- Temporarily rollback CI to
ubuntu-20.04
by @Gedochao in #1640 - Fix - merge extra repos with resolve.repositories by @lwronski in #1643
- Use Mill directory convention in mill project by @lolgab in #1676
Updates & maintenance
- Update coursier-jvm_2.13, ... to 2.1.0-RC3 by @scala-steward in #1688
- Update coursier-jvm_2.13, ... to 2.1.0-RC3-1 by @scala-steward in #1702
- Update slf4j-nop to 2.0.6 by @scala-steward in #1691
- Ignore
jsoniter
updates for JDK 8 by @lwronski in #1694 - Update trees_2.13 to 4.7.0 by @scala-steward in #1690
- Update jsoniter-scala-core_2.13 to 2.19.1 by @scala-steward in #1674
- Update jsoniter-scala-core_2.13 to 2.19.0 by @scala-steward in #1672
- Update os-lib to 0.9.0 by @scala-steward in #1653
- Update scala-collection-compat to 2.9.0 by @scala-steward in #1657
- Update core_2.13 to 3.8.5 by @scala-steward in #1655
- Update pprint to 0.8.1 by @scala-steward in #1654
- Update mill-main to 0.10.10 by @scala-steward in #1652
- Update org.eclipse.jgit to 6.4.0.202211300538-r by @scala-steward in #1656
- Update jsoniter-scala-core_2.13 to 2.18.1 by @scala-steward in #1651
- Update slf4j-nop to 2.0.5 by @scala-steward in #1658
- Bump VirtusLab/scala-cli-setup from 0.1.17 to 0.1.18 by @dependabot in #1644
- Update scala-cli.sh launcher for 0.1.18 by @github-actions in #1624
- Update using_directives to 0.0.10 by @scala-steward in #1692
- Bumped up com.lihaoyi::os-lib version to 0.9.0 by @pingu1m in #1649
New Contributors
- @pingu1m made their first contribution in #1649
- @clutroth made their first contribution in #1660
- @MFujarewicz made their first contribution in #1661
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.18...v0.1.19
v0.1.18
Filter tests with --test-only
It is now possible to filter test suites with the --test-only
option.
//> using dep "org.scalameta::munit::1.0.0-M7"
package tests.only
class Tests extends munit.FunSuite {
test("bar") {
assert(2 + 2 == 5)
}
test("foo") {
assert(2 + 3 == 5)
}
test("foo-again") {
assert(2 + 3 == 5)
}
}
package tests
class HelloTests extends munit.FunSuite {
test("hello") {
assert(2 + 2 == 4)
}
}
scala-cli test BarTests.scala HelloTests.scala --test-only 'tests.only*'
# tests.only.Tests:
# ==> X tests.only.Tests.bar 0.037s munit.FailException: ~/project/src/test/BarTests.scala:5 assertion failed
# 4: test("bar") {
# 5: assert(2 + 2 == 5)
# 6: }
# at munit.FunSuite.assert(FunSuite.scala:11)
# at tests.only.Tests.$init$$$anonfun$1(BarTests.scala:5)
# at tests.only.Tests.$init$$$anonfun$adapted$1(BarTests.scala:6)
# + foo 0.004s
# + foo-again 0.001s
Filtering particular tests by name requires passing args to the test framework.
For example, with munit
:
scala-cli test BarTests.scala HelloTests.scala --test-only 'tests.only*' -- '*foo*'
# tests.only.Tests:
# + foo 0.032s
# + foo-again 0.001s
Accept authenticated proxy params via Scala CLI config
If you can only download artifacts through an authenticated proxy, it is now possible to configure it
with the config
subcommand.
scala-cli config httpProxy.address https://proxy.company.com
scala-cli config httpProxy.user _encoded_user_
scala-cli config httpProxy.password _encoded_password_
Replace _encoded_user_
and _encoded_password_
by your actual user and password, following
the password option format. They should typically look like
env:ENV_VAR_NAME
, file:/path/to/file
, or command:command to run
.
Added by @alexarchambault in #1593
Support for running Markdown sources from zipped archives and gists
It is now possible to run .md
sources inside a .zip
archive.
Same as with directories, .md
sources inside zipped archives are ignored by default, unless
the --enable-markdown
option is passed.
scala-cli archive-with-markdown.zip --enable-markdown
This also enables running Markdown sources fom GitHub gists, as those are downloaded by Scala CLI as zipped archives.
scala-cli https://gist.github.com/Gedochao/6415211eeb8ca4d8d6db123f83f0f839 --enable-markdown
It is also possible to point Scala CLI to a .md
file with a direct URL.
scala-cli https://gist.githubusercontent.com/Gedochao/6415211eeb8ca4d8d6db123f83f0f839/raw/4c5ce7593e19f1390555221e0d076f4b02f4b4fd/example.md
Support for running piped Markdown sources
Instead of passing paths to your Markdown sources, you can also pipe your code via standard input:
echo '# Example Snippet
```scala
println("Hello")
```' | scala-cli _.md
Support for running Markdown snippets
It is now possible to pass Markdown code as a snippet directly from the command line.
scala-cli run --markdown-snippet '# Markdown snippet
with a code block
```scala
println("Hello")
```'
Customize exported Mill project name
It is now possible to pass the desired name of your Mill project to the export
sub-command
with the --project
option.
scala-cli export . --mill -o mill-proj --project project-name
Added by @carlosedp in #1563
Export Scala compiler options to Mill projects
It is now possible to export scalac
options from a Scala CLI project to Mill with the export
sub-command.
Other changes
Fixes
- Fix overriding settings from tests by @alexarchambault in #1566
- Print compilation failed in watch mode too in test command by @alexarchambault in #1548
- Fix error message when running JVM launcher from Java 8 by @alexarchambault in #1575
- Fix
using
directives for Markdown inputs by @Gedochao in #1598 - Fix - clean up only homebrew-scala-experimental directory by @lwronski in #1615
- Warn users when pushing to Sonatype with missing credentials or params by @alexarchambault in #1545
- Warning for multiple files with using directives by @wleczny in #1591
- Make package --python work by @alexarchambault in #1531
- Better revolver output by @alexarchambault in #1614
- Make
PackageTestsDefault.reuse run native binary
more robust by @lwronski in 1621
Documentation updates
- Add some explanations on implicit sub-commands in
-help
by @Gedochao in #1587 - Runner specification by @romanowski in #1445
- Install documentation update by @wleczny in #1595
- Document recent features & changes affecting working with Markdown inputs by @Gedochao in #1606
- Improve docs coverage with
sclicheck
by @Gedochao in #1612 - Reduce ignore tags in the docs snippets by @Gedochao in #1617
Build and internal changes
- Remove superfluous annotation by @alexarchambault in #1567
- Decompose & refactor
Inputs
by @Gedochao in #1565 - Disable create PGP key test on Windows CI by @alexarchambault in #1588
- Switch to Scala 3-based case-app by @alexarchambault in #1568
- Remove cli-options module by @alexarchambault in #1552
- Enable to force using jvm signing launcher for native launcher of scala-cli by @lwronski in #1597
- Run warm up test before running default tests by @lwronski in #1599
- Make DefaultTests more robust by @alexarchambault in #1613
Updates & maintenance
- Update scala-cli.sh launcher for 0.1.17 by @github-actions in #1564
- Update zip-input-stream to 0.1.1 by @scala-steward in #1573
- Update coursier-jvm_2.13, ... to 2.1.0-RC1 by @scala-steward in #1572
- Update mill-main to 0.10.9 by @scala-steward in #1571
- Update test-runner, tools to 0.4.8 by @scala-steward in #1574
- Update case-app_2.13 to 2.1.0-M21 by @scala-steward in #1570
- Bump VirtusLab/scala-cli-setup from 0.1.16 to 0.1.17 by @dependabot in #1579
- Bump Ammonite to 2.5.5-17-df243e14 & Scala to 3.2.1 by @Gedochao in #1586
- Update scala-cli-signing to 0.1.13 by @alexarchambault in #1569
- Update coursier-jvm_2.13, ... to 2.1.0-RC2 by @scala-steward in #1590
- Update scalajs-sbt-test-adapter_2.13 to 1.11.0 by @scala-steward in #1477
- Update slf4j-nop to 2.0.4 by @scala-steward in #1596
- Update jsoniter-scala-core_2.13 to 2.18.0 by @scala-steward in #1608
- Update test-runner, tools to 0.4.9 by @scala-steward in #1610
- Update Bloop to 1.5.4-sc-4 by @alexarchambault in #1622
New Contributors
- @carlosedp made their first contribution in #1563
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.17...v0.1.18
v0.1.17
SDKMAN and Homebrew support installation of Scala CLI for M1
To install Scala CLI via SDKMAN, run the following command from the command line:
sdk install scalacli
and to install Scala CLI via homebrew:
brew install Virtuslab/scala-cli/scala-cli
Added by @wleczny in #1505 and #1497
Specifying the --jvm
option via using directives
The --jvm
option can now be added via using directives, like
//> using jvm "adopt:11"
Accept more scalac
options without escaping
Scala CLI now accepts options such as -rewrite
, -new-syntax
, -old-syntax
, -source:<target>
, -indent
and -no-indent
, without requiring them to be escaped by -O
.
Enable python
support via using directives
The --python
option can now be enabled via a using directive, like
//> using python
Added by @alexarchambault in #1492
Other changes
Publish
- Various config command tweaks / fixes by @alexarchambault in #1460
- Accept email via --email when creating a PGP key in config command by @alexarchambault in #1482
- Make publish --python work by @alexarchambault in #1494
- Add repositories.credentials config key by @alexarchambault in #1466
- Check for missing org and version at the same time in publish by @alexarchambault in #1534
- Rename some publish config keys by @alexarchambault in #1532
- Add publish.credentials config key, use it to publish by @alexarchambault in #1533
Spark
- Accept spark-submit arguments on the command-line by @alexarchambault in #1455
Fixes
- Fix generating pkg package for M1 by @lwronski in #1461
- Return exit code 1 when build fails for test by @lwronski in #1518
- Fix the
nativeEmbedResources
using directive by @Gedochao in #1525
Build and internal changes
- Automate deploy of scala-experimental brew formula by @wleczny in #1530
- Decompose RunTestDefinitions by @Gedochao in #1529
- Add some simple tests for running
.md
sources by @Gedochao in #1527 - Run doc tests from munit test suites by @alexarchambault in #1435
- Minor refacto around build options stuff by @alexarchambault in #1488
- No need to use os.ProcessOutput.ReadLines in test by @alexarchambault in #1491
- Enforce logging options for all scala commands by @Gedochao in #1499
- Tweak documentation verification tests by @Gedochao in #1504
- Support
jvmRunEnvironment
andjvmTestEnvironment
for BSP by @Gedochao in #1519 - Downgrade Scala version in 'scala-cli repl --amm' if needed by @alexarchambault #1493
Documentation / help updates
- Tweak / fix publish messages by @alexarchambault in #1535
- Merge documentation of installing scala-cli on MacOs and MacOs/M1 by @wleczny in #1507
- Improve the basics doc by @Gedochao in #1513
- Fix a typo in the
--server
option reference doc by @Gedochao in #1521 - Improve the docs on using Scala compiler options by @Gedochao in #1503
- Add help for repl, scalafmt and scaladoc by @wleczny in #1487
- remove paragraph about bug for coursier install by @bishabosha in #1485
- Tell about pressing Enter in watch message by @alexarchambault in #1465
Updates / maintainance
- Update jsoniter-scala-core_2.13 to 2.17.9 by @scala-steward in #1544
- Bump docusaurus to 2.20 and other docs deps by @lwronski in #1540
- Update jsoniter-scala-core_2.13 to 2.17.8 by @scala-steward in #1537
- Update cli-options_2.13, cli_2.13, ... to 0.1.11 by @scala-steward in #1538
- Update case-app_2.13 to 2.1.0-M19 by @scala-steward in #1536
- Bump coursier/setup-action from 1.2.1 to 1.3.0 by @dependabot in #1496
- Update scala-cli.sh launcher for 0.1.16 by @github-actions in #1458
- Bump VirtusLab/scala-cli-setup from 0.1.15 to 0.1.16 by @dependabot in #1462
- Update expecty to 0.16.0 by @scala-steward in #1467
- Update jsoniter-scala-core_2.13 to 2.17.5 by @scala-steward in #1470
- Update mill-main to 0.10.8 by @scala-steward in #1472
- Update pprint to 0.8.0 by @scala-steward in #1473
- Update core_2.13 to 3.8.3 by @scala-steward in #1474
- Update publish_2.13 to 0.1.3 by @scala-steward in #1475
- Update trees_2.13 to 4.6.0 by @scala-steward in #1478
- Update slf4j-nop to 2.0.3 by @scala-steward in #1479
- Update asm to 9.4 by @scala-steward in #1476
- Update using_directives to 0.0.9 by @scala-steward in #1480
- Update fansi to 0.4.0 by @scala-steward in #1471
- Update case-app_2.13 to 2.1.0-M18 by @scala-steward in #1468
- Bump webfactory/ssh-agent from 0.5.4 to 0.7.0 by @dependabot in #1495
- Update jsoniter-scala-core_2.13 to 2.17.6 by @scala-steward in #1498
- Update coursier to 2.1.0-M7-39-gb8f3d7532 by @alexarchambault in #1520
New Contributors
- @bishabosha made their first contribution in #1485
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.16...v0.1.17
v0.1.16
This release consists mainly of updates, fixes, and various enhancements of existing features.
Specifying javac options via using directives
javac options can now be added via using directives, like
//> using javacOpt "source", "1.8", "target", "1.8"
Pressing enter in watch mode proceeds to run / compile / test / … again
In watch mode (using the -w
or --watch
option), pressing Enter when Scala CLI is watching for changes makes it run again what it's supposed to be doing (compiling, running, running tests, or packaging, etc.) This is inspired by Mill's behaviour in watch mode, which supports the same feature.
Added by @alexarchambault in #1451
Installation via Scoop on Windows
Scala CLI can now be installed via Scoop on Windows, with a command such as
scoop install scala-cli
Added by @nightscape in #1416, thanks to him!
Actionable diagnostics in Metals
Scala CLI should now send text edit suggestions with some of its diagnostics, via BSP, so that editors can suggest those edits to users. This should work in upcoming versions of Metals in particular.
Other
- Add
--scalapy-version
option by @alexarchambault in #1397
Fixes
Fixes in Scala Native binaries caching
When running a sequence of commands such as
$ scala-cli run --native .
$ scala-cli --power package --native . -o my-app
Scala CLI should cache a Scala Native binary during the first command, so that the second command can just re-use it, rather than generating a binary again. This also fixes the re-use of compilation artifacts between both commands, so that the Scala CLI project isn't re-compiled during the second command either.
Fixed by @alexarchambault in #1406
Accept more scalac options without escaping
Scala CLI now accepts options such as -release
, -encoding
, -color
, -feature
, -deprecation
and -nowarn
, without requiring them to be escaped by -O
. It also accepts --scalac-verbose
, which is equivalent to -O -verbose
(increases scalac verbosity). Lastly, it warns when -release
and / or -target:<target>
are inconsistent with --jvm
.
Fix --java-option
and --javac-option
handling in package
sub-command
--java-option
and --javac-option
should now be accepted and handled properly in the package
sub-command.
Fix wrong file name when publising Scala.js artifacts locally
The publish local
sub-command used to publish Scala.js artifacts with a malformed suffix. This is now fixed.
Fix spurious stack traces in the publish
and publish local
sub-commands
The publish
and publish local
commands could print spurious stack traces when run with non-default locales, using native Scala CLI binaries. This is now fixed.
Fixed by @romanowski in #1423
Make run --python --native
work from Python virtualenv
Using both --native
and --python
in the run
sub-command should work fine from Python virtualenv.
Documentation / help updates
- Dump scala 2 version in docs by @lwronski in #1408
- Ensure the the
repl
& default sub-commands respect group help options by @Gedochao in #1417 - Remove stray
_
typo by @armanbilge in #1385 - Add docs on how to install scala-cli for M1 by @lwronski in #1431
- Debugging cookbook by @wleczny in #1441
Updates / maintainance
- Update scala-cli.sh launcher for 0.1.15 by @github-actions in #1401
- Revert scalafmt fix by @lwronski in #1402
- Bump respective Scala versions to
2.12.17
&2.13.9
and Ammonite to2.5.4-33-0af04a5b
by @Gedochao in #1405 - Turn off running tests in PR for M1 runner by @lwronski in #1403
- Bump VirtusLab/scala-cli-setup from 0.1.14.1 to 0.1.15 by @dependabot in #1414
- Bump coursier/setup-action from f883d08305acbc28e5e5363bf5ec086397627021 to 1.2.1 by @dependabot in #1415
- Tweak the release procedure by @Gedochao in #1426
- Update case-app_2.13 to 2.1.0-M17 & scala-cli-signing to v0.1.10 by @lwronski in #1427
- Automate choco package deploy by @wleczny in #1412
- Generate pkg package for m1 by @lwronski in #1410
- Re-enable gif tests by @alexarchambault in #1436
- Bump Scala 2.13.x to 2.13.10 & Ammonite to 2.5.5 by @Gedochao in #1437
- Remove mill-scala-cli stuff from build by @alexarchambault in #1433
- Add support for BSP's
buildTarget/outputPaths
and update bsp4j to 2… by @lwronski in #1439 - Update bsp4j to 2.1.0-M3 by @lwronski in #1444
- Update scala-packager to 0.1.29 and hardcode upgradeCodeGuid by @lwronski in #1446
- Refactor
ScalaCommand
to enforce respecting help options by @Gedochao in #1440 - Address compilation warnings by @alexarchambault in #1452
- Update coursier to 2.1.0-M7 by @alexarchambault in #1447
- Update bloop to 1.5.4-sc-3 by @alexarchambault in #1454
New Contributors
- @nightscape made their first contribution in #1416
- @kiendang made their first contribution in #1399
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.15...v0.1.16
v0.1.15
The M1 native launcher is here! (experimental)
We are happy to announce that there is a new dedicated launcher for M1 users. You can find it here.
Please note that the package
sub-command is unstable for this launcher.
--python
option for repl
sub-command (experimental)
Passing the --python
option allows using ScalaPy
with the repl
sub-command:
▶ scala-cli --python
Welcome to Scala 3.2.0 (17.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> import me.shadaj.scalapy.py
scala> py.Dynamic.global.range(1, 4)
val res0: me.shadaj.scalapy.py.Dynamic = range(1, 4)
Added in #1336 by @alexarchambault
-d
, -classpath
and compile
sub-command's --output
options changes
To be backward compatible with the scala
command, some changes have been made to the following options:
- The
compile
sub-command's--output
option has been renamed to--compilation-output
. This option is now also available from therun
andpackage
sub-commands.
▶ scala-cli compile Hello.scala --compilation-output out
▶ scala-cli --main-class Hello -classpath out
Hello
- The
-d
option is no longer an alias for--dependency
, but for--compilation-output
.-O -d -O path/to/compilation/output
now defaults to-d path/to/compilation/output
.
▶ scala-cli compile Hello.scala -d out
▶ scala-cli --main-class Hello -classpath out
Hello
- The old
--classpath
option has been renamed to--print-classpath
.--classpath
,--class-path
and-classpath
options are now aliases for the--extra jars
option.-O -classpath -O path/to/classpath
now defaults to--extra-jars path/to/classpath
.
▶ scala-cli compile --print-classpath Hello.scala
# ~/Projects/debug-test/.scala-build/project_103be31561_103be31561-7a1ed8dde0/classes/main:~/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.2.0/scala3-library_3-3.2.0.jar:~/Library/Caches/ScalaCli/local-repo/v0.1.15/org.virtuslab.scala-cli/runner_3/0.1.15/jars/runner_3.jar:~/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.8/scala-library-2.13.8.jar
Make inputs optional when -classpath
and --main-class
are passed
The following changes have been made to improve backward compatibility with the scala
command:
- Passing the
--main-class
option along with-classpath
to the default command now defaults torun
instead ofrepl
:
▶ scala-cli --main-class Hello -classpath out
Hello
- If the
run
sub-command is passed explicitly, it's sufficient to have a main class on the classpath (inputs aren't necessary then):
▶ scala-cli compile Hello.scala -d out
▶ scala-cli run -classpath out
Hello
Debugging with the run
and test
sub-commands
It is now possible to debug code ran by run
and test
sub-commands:
▶ scala-cli Main.scala --debug
Listening for transport dt_socket at address: 5005
Hello
This addresses #1212
--platform
option
This option can be used to choose the platform, which should be used to compile and run the application.
▶ scala-cli Main.scala --platform js
Hello
Note that --platform js
is an alias for --js
and --platform native
is an alias for --native
.
This addresses #1214
Other changes
Fixes
- Ensure directories are created recursively when the
package
sub-command is called by @Gedochao in #1371 - Fix calculation of Scala version and turn off the
-release
flag for 2.12.x < 2.12.5 by @Gedochao in #1377 - Fix finding main classes in external jars by @Gedochao in #1380
- Fix Js split style SmallModulesFor in pure JVM by @lwronski in #1394
Build and internal changes
- Remove mill-scalafix customization by @alexarchambault in #1360
- Split config db stuff to a separate config module by @alexarchambault in #1367
- Detect sip when installed by coursier by @lwronski in #1368
- Create empty class to enforce resolving ivy deps by mill for dummy modules by @lwronski in #1374
- Use millw launcher instead of running mill by cs by @lwronski in #1375
- Add --debug option for integration tests by @wleczny in #1378
- NIT ScalaVersionUtil refactor by @Gedochao in #1384
- Make config module compatible with Java 8 by @alexarchambault in #1387
- Add HTTP proxy-related keys in config module by @alexarchambault in #1388
- Add repositories-related keys in config module by @alexarchambault in #1395
Updates
- Update scala-cli.sh launcher for 0.1.14 by @github-actions in #1362
- Update jsoniter-scala-core_2.13 to 2.17.3 by @scala-steward in #1364
- Update core_2.13 to 3.8.0 by @scala-steward in #1365
- Bump VirtusLab/scala-cli-setup from 0.1.13 to 0.1.14.1 by @dependabot in #1376
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.14...v0.1.15
v0.1.14
Hotfix printing stacktraces from Scala CLI runner for Scala 3.x < 3.2.0
We fixed a nasty bug breaking any Scala CLI run using any Scala 3 version earlier than 3.2.0 on printing stacktraces. Only Scala CLI 0.1.13 was affected.
$ scala-cli about
Scala CLI version: 0.1.13
Scala version (default): 3.2.0
$ scala-cli -S 3.1.3 -e 'throw Exception("Broken")'
Compiling project (Scala 3.1.3, JVM)
Compiled project (Scala 3.1.3, JVM)
Exception in thread "main" java.lang.NoSuchMethodError: 'long scala.runtime.LazyVals$.getOffsetStatic(java.lang.reflect.Field)'
at scala.cli.runner.StackTracePrinter.<clinit>(StackTracePrinter.scala:101)
at scala.cli.runner.StackTracePrinter$.coloredStackTraces(StackTracePrinter.scala:104)
at scala.cli.runner.StackTracePrinter$.$lessinit$greater$default$4(StackTracePrinter.scala:11)
at scala.cli.runner.Runner$.main(Runner.scala:18)
at scala.cli.runner.Runner.main(Runner.scala)
Added in #1358 by @romanowski
Build and internal changes
- Disable mill-scala-cli for now by @alexarchambault in #1335
- Update scala-cli.sh launcher for 0.1.13 by @github-actions in #1351
- Remove backslash which skip execution of
mv
command by @lwronski in #1353 - Fix import ordering by @alexarchambault in #1359
Updates
- Update scalafix stuff… by @alexarchambault in #1333
- Bump VirtusLab/scala-cli-setup from 0.1.12 to 0.1.13 by @dependabot in #1354
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.13...v0.1.14
v0.1.13
Change the default sub-command to repl
when no args are passed
We no longer default to the help
sub-command when no arguments are passed. Starting with 0.1.13
running Scala CLI with no args will launch the repl
.
$ scala-cli -S 3
Welcome to Scala 3.1.3 (17.0.3, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala>
When inputs are provided, Scala CLI defaults to the run
sub-command, as before.
$ cat hello.sc
println("Hello World")
$ scala-cli hello.sc
Hello World
This change was added by @Gedochao in #1268
Marking the project's workspace root with the project.settings.scala
file
Scala CLI now supports marking the workspace root directory with an optional configuration file: project.settings.scala
. The workspace root determines where the .bsp
and .scala-build
directories will be saved (which mostly affects what path should be opened in your IDE to import the Scala CLI project through BSP).
The settings file is also the recommended input for your project's using directives
. Otherwise, it functions similarly to other .scala
sources.
$ cat project.settings.scala
//> using scala "2.13.4"
$ cat hello.sc
println(util.Properties.versionString)
$ scala-cli hello.sc .
version 2.13.4
To see how exactly is the root directory resolved, see this document
Scala CLI is now built with Scala 3.2.0
We now rely on Scala 3.2.0
as the default internal Scala version used to build the project.
This change was added by @lwronski in #1314
Add resources support for Scala Native
Scala CLI now allows embedding resources (by default) in a Scala Native binary with the --native
flag.
$ cat resources/scala-native/foo.c
int foo(int i) {
return i + 42;
}
$ cat hello.scala
//> using platform "native"
//> using resourceDir "resources"
import scalanative.unsafe.*
@extern
def foo(int: CInt): CInt = extern
@main def main =
println(foo(3))
$ scala-cli hello.scala --native
45
Default to the run
sub-command instead of repl
when the -e
, --execute-script
, --execute-scala
or --execute-java
options are passed.
Even though we default to the repl
sub-command when no arguments are passed to Scala CLI, an exception to that rule is when a snippet is passed with one of the following options: -e
, --execute-script
, --execute-scala
or --execute-java
. In that case, the passed snippets are treated as inputs to be executed and switch the default to the run
sub-command.
$ scala-cli -e 'println("Hello")'
Hello
If you still want to pass a snippet to the repl
, you can either pass the repl
sub-command explicitly or use one of the following options, as before: --script-snippet
, --scala-snippet
or --java-snippet
.
$ scala-cli --script-snippet 'println("Hello")'
Welcome to Scala 3.1.3 (17.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> snippet_sc.main(Array.empty)
Hello
This change was introduced to make the -e
option backwards compatible with the scala
command.
Work in progress
Support for Markdown (experimental)
Scala CLI can now accept .md
inputs and run/compile a snippet of Scala code inside the markdown. Markdown sources are ignored by default unless passed explicitly as inputs. You can also enable including non-explicit .md
inputs by passing the --enable-markdown
option.
Plain scala
snippets are treated similarly to .sc
scripts which can be run by scala-cli
:
$ cat Example.md
This is a simple example of an `.md` file with a Scala snippet.
```scala
val message = "Hello from Markdown"
println(message)
```
scala-cli Example.md
Hello from Markdown
See this document for more details about the experimental Markdown support.
Add --python
option for the run
sub-command (experimental)
The run
sub-command can now run ScalaPy when the --python
option is passed.
$ cat helloscalapy.sc
import py.SeqConverters
val len = py.Dynamic.global.len(List(0, 2, 3).toPythonProxy)
println(s"Length is $len")
$ scala-cli helloscalapy.sc --python -S 2.13
Length is 3
Added in #1295 by @alexarchambault
Other changes
Documentation
- Correct using directives on configuration.md by @megri in #1278
- Improve dependencies doc by @Gedochao in #1287
Fixes
Build and internal changes
- Improve the error message for when a build's main class is ambiguous by @Gedochao in #1323
- Improve the error message for unsupported Scala version with Ammonite by @Gedochao in #1327
- Detect ARM64 macs when downloading coursier launcher by @keynmol in #1282
- Make test("...".only) work again in RunTestDefinitions by alexarchambault in #1294
- Use os-lib short-hand method trim when possible by alexarchambault in #1334
- Add missing repl tests by alexarchambault in #1332
- Scala CLI deb package - Priority and Section flag by @lwronski in #1338
Updates
- Update ammonite to 2.5.4-16-7317286d by @scala-steward in #1283
- Update mill-main to 0.10.7 by @scala-steward in #1284
- Update scalajs-env-nodejs_2.13 to 1.4.0 by @scala-steward in #1303
- Update jsoniter-scala-core_2.13 to 2.16.0 by @scala-steward in #1302
- Update core_2.13 to 3.7.6 by @scala-steward in #1299
- Update ammonite to 2.5.4-19-cd76521f by @scala-steward in #1298
- Update bsp4j to 2.1.0-M1 by @lwronski in #1277
- Bump VirtusLab/scala-cli-setup from 0.1.11 to 0.1.12 by @dependabot in #1306
- Update jsoniter-scala-core_2.13 to 2.17.0 by @scala-steward in #1311
- Update test-runner, tools to 0.4.7 by @scala-steward in #1317
- Update jsoniter-scala-core_2.13 to 2.17.1 by @scala-steward in #1320
- Update ammonite_3.1.3 to 2.5.4-22-4a9e6989 by @scala-steward in #1329
- Update jsoniter-scala-core_2.13 to 2.17.2 by @scala-steward in #1343
- Update python-native-libs to 0.2.4 by @scala-steward in #1341
- Update org.eclipse.jgit to 6.3.0.202209071007-r by @scala-steward in #1344
New Contributors
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.12...v0.1.13
v0.1.12
Add --spark
, --spark-standalone
and --hadoop
options for the run
sub-command
The run
sub-command can now run Spark jobs when the --spark
option is passed.
$ scala-cli run --spark SparkJob.scala
Similarly, it's possible to run Hadoop jobs by passing the --hadoop
option.
scala-cli run --hadoop HadoopJob.java
It's also possible to run Spark jobs without a Spark distribution by passing the --spark-standalone
option.
$ scala-cli run --spark-standalone SparkJob.scala
Added in #1129 by alexarchambault
Add the default Scala version to the output of the version
sub-command
The version
sub-command now includes both the Scala CLI version and the default Scala version.
$ scala-cli --version
Scala CLI version 0.1.12
Default Scala version: 3.1.3
$ scala-cli -version
Scala CLI version 0.1.12
Default Scala version: 3.1.3
$ scala-cli version
Scala CLI version 0.1.12
Default Scala version: 3.1.3
You can also pass the --cli-version
option to only get the Scala CLI version or the --scala-version
option
to only get the default Scala version.
$ scala-cli version --cli-version
0.1.12
$ scala-cli version --scala-version
3.1.3
This is potentially a breaking change if your automation relies on the output of the version
sub-command.
Enable passing the scalafmt
configuration with --scalafmt-conf
and --scalafmt-conf-str
It is now possible to pass a custom location of the scalafmt
configuration with the --scalafmt-conf
option for the
fmt
sub-command.
$ scala-cli fmt --scalafmt-conf path/to/the/conf/.scalafmt.conf
You can also pass the configuration straight from the terminal with --scalafmt-conf-str
.
$ scala-cli fmt --scalafmt-conf-str "version=3.5.5
runner.dialect=scala213"
Enable turning the --interactive
mode on permanently
It is now possible to set the --interactive
mode on by default, so that passing it explicitly isn't necessary.
The next time when you run a command with the --interactive
option set to on, Scala CLI will suggest to turn it on
permanently.
This is recommended for environments where scala-cli
is used by a human user only (and not by any automation).
$ scala-cli . --interactive
You have run the current scala-cli command with the --interactive mode turned on.
Would you like to leave it on permanently?
[0] Yes
[1] No
0
--interactive is now set permanently. All future scala-cli commands will run with the flag set to true.
If you want to turn this setting off at any point, just run `scala-cli config interactive false`.
Found several main classes. Which would you like to run?
[0] ScalaMainClass2
[1] ScalaMainClass1
[2] scripts.ScalaScript_sc
You can also configure it manually with the config
sub-command, by setting the interactive
property to true
.
$ scala-cli config interactive true
Other changes
Work in progress
SIP-46-related
- Restrict directives based on the command used by romanowski in #1259
Documentation
- NIT Improve some website docs by BlackAnubis7 in #1243
Build and internal changes
- Add 0.1.11 release notes to release_notes.md by BlackAnubis7 in #1228
- Temporary disable test gif by lwronski in #1261
- aarch64 fixes by alexarchambault in #1180
Updates
- Update mill launcher by alexarchambault in #1269
- Update scala-cli.sh launcher for 0.1.11 by github-actions in #1230
- Update jsoniter-scala-core_2.13 to 2.13.39 by scala-steward in #1239
- Update trees_2.13 to 4.5.12 by scala-steward in #1242
- Update jsoniter-scala-core_2.13 to 2.14.2 by scala-steward in #1241
- Update org name to VirtusLab for downloading scalafmt-native-image by lwronski in #1253
- Update core_2.13 to 3.7.4 by scala-steward in #1247
- Update case-app_2.13 to 2.1.0-M15 by scala-steward in #1245
- Update jsoniter-scala-core_2.13 to 2.15.0 by scala-steward in #1246
- Update cli-options_2.13, cli_2.13, ... to 0.1.8 by scala-steward in #1248
- Update metaconfig-typesafe-config to 0.11.1 by scala-steward in #1254
- Update ammonite to 2.5.4-14-dc4c47bc by scala-steward in #1255
- Update coursier-jvm_2.13, ... to 2.1.0-M6-53-gb4f448130 by scala-steward in #1256
- Update scala-packager-cli_2.13, ... to 0.1.27 by scala-steward in #1258
- Update bloop-config_2.13 to 1.5.3-sc-1 by scala-steward in #1257
- Update ammonite to 2.5.4-15-f4a8969b by scala-steward in #1264
- Update trees_2.13 to 4.5.13 by scala-steward in #1265
- Update slf4j-nop to 2.0.0 by scala-steward in #1273
- Update cli-options_2.13, cli_2.13, ... to 0.1.9 by scala-steward in #1272
- Bump VirtusLab/scala-cli-setup from 0.1.5 to 0.1.11 by dependabot in #1274
New Contributors
- BlackAnubis7 made their first contribution in #1228
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.11...v0.1.12
v0.1.11
Make .scalafmt.conf
optional when running the fmt
command
Scala CLI can now run the fmt
command without a .scalafmt.conf
file present. Previously, if such a file was absent, a Scalafmt requires explicitly specified version.
error was raised while using the fmt
command.
The Scala CLI fmt
command now supports passing the scalafmt
version and dialect directly from the command line, using the --scalafmt-dialect
and --scalafmt-version
options respectively:
scala-cli fmt --scalafmt-dialect scala3 --scalafmt-version 3.5.8
Either of those (or both) can be skipped, which will make Scala CLI infer a default value.
The configuration used can be saved in the workspace by passing the --save-scalafmt-conf
option.
Define output
option for package
command with using directives
It is now possible to pass the output
option of the package
command with using directives instead of passing it directly from bash.
Add support for running multiple snippets of the same kind
Scala CLI now allows to pass multiple snippets of the same kind.
It was previously possible to mix different kinds (so to pass a Java snippet alongside a Scala one), but not for example 2 separate Scala snippets. That limitation no longer applies.
When passed this way, each snippet is then treated as a separate input by Scala CLI.
$ scala-cli --scala-snippet '@main def main() = println(Messages.hello)' --scala-snippet 'object Messages { def hello = "Hello" }'
Hello
Add bloop sub-command
Scala CLI now has a (hidden for now) bloop sub-command, that runs a command using the Scala CLI Bloop server (while the mainline Bloop bloop CLI uses its default Bloop server). This is handy when debugging things on Scala CLI for example, allowing one to manually run scala-cli bloop projects or scala-cli bloop compile.
Added in #1199 by alexarchambault
Make main class optional in preamble-less assemblies
It is now allowed to generate an assembly, even for code that has no main class, when --preamble=false
is passed. This can be useful for libraries, if users want to pass the assembly to tools such as proguard. This also accepts a (hidden) --main-class-in-manifest=false
option if users want not only no preamble, but also no mention of main class in the assembly manifest (META-INF/MANIFEST.MF
in the assembly JAR). The latter option is useful for tools, such as the hadoop jar command, that behave differently depending on the presence or not of a main class in the manifest.
Added in #1200 by alexarchambault
Important fixes & enhancements
Prevent erroneous using directives from blocking the initial run of BSP
Up till now, running the setup-ide
sub-command on sources containing using directives
with syntax errors or pointing to dependencies which could not be fetched would create a BSP
setup which could not be imported correctly by IDEs. This is no longer the case and such a BSP
connection should now import correctly, so that it's possible to fix the faulty code within the comfort of one's IDE of choice.
This fixes #1097
Work in progress
Allow to globally turn actionable diagnostics on or off
It is now possible to globally enable or disable actionable diagnostics using the config
sub-command.
The relevant configuration is under the actions
key.
$ scala-cli config actions true
Publishing-related features
- Add "publish setup" command by alexarchambault in #926
Other changes
Documentation
- Put the release notes doc on the website by Gedochao in #1196
- Fix typo in Spark docs by alexarchambault in #1183
- Tweak issue templates & the release procedure by Gedochao in #1188
- Add install and uninstall completions documentation by wleczny in #1201
Build and internal changes
- ignore *.semanticdb files by mtk in #1187
- Update scala-cli.sh launcher for 0.1.10 by github-actions in #1185
- Force push updating scala-cli in scala-cli-setup by lwronski in #1189
- Fix running scala check in scala native by lwronski in #1190
- Use manifest JARs in "run" command if needed by alexarchambault in #1198
- Use more lightweight Spark distribs in spark tests by alexarchambault in #1207
- Update GraalVM to 22.2.0 by alexarchambault in #1208
- Split integration tests by alexarchambault in #1202
- Debug macOS CI issue on CI by alexarchambault in #1215
- Update docusaurus to 2.0.0-rc.1 by lwronski in #1224
Updates
- Update core_2.13 to 3.7.0 by scala-steward in #1186
- Update core_2.13 to 3.7.1 by scala-steward in #1194
- Update jsoniter-scala-core_2.13 to 2.13.37 by scala-steward in #1197
- Update jsoniter-scala-core_2.13 to 2.13.38 by scala-steward in #1217
- Update ammonite to 2.5.4-13-1ebd00a6 by scala-steward in #1218
- Update core_2.13 to 3.7.2 by scala-steward in #1219
- Update scala-collection-compat to 2.8.1 by scala-steward in #1221
- Update trees_2.13 to 4.5.11 by scala-steward in #1222
- Update coursier-jvm_2.13, ... to 2.1.0-M6-49-gff26f8e39 by scala-steward in #1223
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.10...v0.1.11
v0.1.10
Initial support for importing other sources via using
directives
It is now possible to add sources to a Scala CLI project from a source file, with using file
directives:
//> using file "Other.scala"
//> using file "extra/"
Note that several sources can be specified in a single directive
//> using file "Other.scala" "extra/"
Add dependency update
sub-command
Scala CLI can now update dependencies in user projects, using the dependency-update
sub-command, like
scala-cli dependency-update --all .
When updates are available, this sub-command asks whether to update each of those, right where these dependencies are defined.
Running snippets passed as arguments
Scala CLI can now run Scala or Java code passed on the command-line, via -e
/ --script-snippet
/ --scala-snippet
/ --java-snippet
:
$ scala-cli -e 'println("Hello")'
Hello
$ scala-cli --script-snippet 'println("Hello")'
Hello
$ scala-cli --scala-snippet '@main def run() = println("Hello")'
Hello
$ scala-cli --java-snippet 'public class Main { public static void main(String[] args) { System.out.println("Hello"); } }'
Hello
These options are meant to be substitutes to the -e
option of the scala
script that ships in scalac archives.
Uninstall instructions and uninstall
sub-command
Uninstalling Scala CLI is now documented in the main installation page, right after the installation instructions. In
particular, when installed via
the installation script, Scala CLI can be
uninstalled via a newly added uninstall
sub-command.
Added in #1122 and #1152 by wleczny.
Important fixes & enhancements
ES modules
Scala CLI now supports the ES Scala.js module kind, that can be enabled via a //> using jsModuleKind "esmodule"
directive, allowing to import other ES modules in particular.
Added in #1142 by hugo-vrijswijk.
Putting Java options in assemblies, launchers, and docker images, in package
sub-command
Passing --java-opt
and --java-prop
options to the package
sub-command is now allowed. The passed options are
hard-coded in the generated assemblies or launchers, and in docker images.
--command
and --scratch-dir
options in run
sub-command
The run
sub-command can now print the command it would have run, rather than running it. This can be useful for
debugging purposes, or if users want to manually tweak commands right before they are run. Pass --command
to run to
enable it. This prints one argument per line, for easier automated processing:
$ scala-cli run --command -e 'println("Hello")' --runner=false
~/Library/Caches/Coursier/arc/https/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%252B8/OpenJDK17U-jdk_x64_mac_hotspot_17.0.2_8.tar.gz/jdk-17.0.2+8/Contents/Home/bin/java
-cp
~/Library/Caches/ScalaCli/virtual-projects/ee/project-3c6fdea1/.scala-build/project_ed4bea6d06_ed4bea6d06/classes/main:~/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.1.3/scala3-library_3-3.1.3.jar:~/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.8/scala-library-2.13.8.jar
snippet_sc
When run
relies on temporary files (when Scala.js is used for example), one can pass a temporary directory
via --scratch-dir
, so that temporary files are kept even when scala-cli
doesn't run anymore:
$ scala-cli run --command -e 'println("Hello")' --js --runner=false --scratch-dir ./tmp
node
./tmp/main1690571004533525773.js
Added in #1163 by by alexarchambault.
Don't put Scala CLI internal modules in packages
Scala CLI doesn't put anymore its stubs module and its "runner" module in generated packages, in the package
sub-command.
Fixed in #1161 by alexarchambault.
Don't write preambles in generated assemblies in the package
sub-command
Passing --preamble=false
to scala-cli --power package --assembly
makes it generate assemblies without a shell preamble. As a
consequence, these assemblies cannot be made executable, but these look more like "standard" JARs, which is required in
some contexts.
Fixed in #1161 by alexarchambault.
Don't put some dependencies in generated assemblies in the package
sub-command
Some dependencies, alongside all their transitive dependencies, can be excluded from the generated assemblies.
Pass --provided org:name
to scala-cli --power package --assembly
to remove a dependency, like
$ scala-cli --power package SparkJob.scala --assembly --provided org.apache.spark::spark-sql
Note that unlike "provided" dependencies in sbt, and compile-time dependencies in Mill, all transitive dependencies are
excluded from the assembly. In the Spark example above, for example, as spark-sql
depends on scala-library
(the
Scala standard library), the latter gets excluded from the assembly too (which works fine in the context of Spark jobs).
Fixed in #1161 by alexarchambault.
In progress
Experimental Spark capabilities
The package
sub-command now accepts a --spark
option, to generate assemblies for Spark jobs, ready to be passed
to spark-submit
. This option is hidden (not printed in scala-cli --power package --help
, only in --help-full
), and should
be considered experimental.
See this document for more details about these experimental Spark features.
Added in #1086 by alexarchambault.
Other changes
Documentation
- Add cookbooks for working with Scala CLI in IDEA IntelliJ by Gedochao in #1149
- Fix VL branding by lwronski in #1151
- Back port of documentation changes to main by github-actions in #1154
- Update using directive syntax in scenarios by lwronski in #1159
- Back port of documentation changes to main by github-actions in #1165
- Add docs depedency-update by lwronski in #1178
- Add docs how to install scala-cli via choco by lwronski in #1179
Build and internal changes
- Update scala-cli.sh launcher for 0.1.9 by github-actions in #1144
- Update release procedure by wleczny in #1156
- chore(ci): add in mill-github-dependency-graph by ckipp01 in #1164
- chore(ci): bump version of mill-github-dependency-graph by ckipp01 in #1171
- Use Scala CLI 0.1.9 in build by alexarchambault in #1173
- Stop compiling most stuff with Scala 2 by alexarchambault in #1113
- Turn the sip mode also for
scala-cli-sip
binary by romanowski in #1168 - chore(ci): use mill-dependency-submission action by ckipp01 in #1174
- Fix snippet tests for Windows by Gedochao in #1172
Updates
- Update mill-main to 0.10.5 by scala-steward in #1148
- Update snailgun-core, snailgun-core_2.13 to 0.4.1-sc2 by scala-steward in #1155
- Update jsoniter-scala-core_2.13 to 2.13.35 by scala-steward in #1169
- Update scala-collection-compat to 2.8.0 by scala-steward in #1170
- Update jsoniter-scala-core_2.13 to 2.13.36 by scala-steward in #1175
New Contributors
- hugo-vrijswijk made their first contribution in #1142
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.9...v0.1.10
v0.1.9
--list-main-classes
for publish
& package
publish
and package
sub-commands now support the --list-main-classes
option, which allows to list all the
available main classes. Previously it was only available in the run
command.
Important fixes & enhancements
fmt
options improvement
Added missing documentation on how to pass native scalafmt
options in the fmt
sub-command with the -F
option.
$ scala-cli fmt -F --version
scalafmt 3.5.2
Additionally, a couple of scalafmt
's native options received aliases in Scala CLI:
--respect-project-filters
is an alias for -F --respect-project-filters
. Because of the way sources are passed by
Scala CLI to scalafmt
under the hood, we now turn it on by default to respect any project.excludePaths
settings in
the user's .scalafmt.conf
.
It can be disabled by passing --respect-project-filters=false
to revert to previous behaviour.
This addresses #1121
--scalafmt-help
is an alias for -F --help
. It shows the --help
output from scalafmt
, which might prove as
helpful reference when in need of using native scalafmt
options with -F
.
Include libsodium.dll
on Windows
Static linking of libsodium in Windows launcher has been fixed. This addresses #1114
Added in #1115 by alexarchambault
Force interactive mode for update
command
Interactive mode for update
sub-command is now enabled by default.
In progress
Publishing-related features
- Publish tweaks + documentation by alexarchambault in #1107
Better BSP support for Scala scripts
- Add scala-sc language to BSP supported languages by alexarchambault in #1140
Other changes
Documentation PRs
- Update scala 2.12 to 2.12.16 in docs by lwronski in #1108
- Back port of documentation changes to main by github-actions in #1111
- Tweak release procedure by Gedochao in #1112
Build and internal changes
- Add choco configuration files by lwronski in #998
- Tweaking by alexarchambault in #1105
- Add scala-cli-setup deploy key to ssh-agent by lwronski in #1117
Updates
- Update scala-cli.sh launcher for 0.1.8 by github-actions in #1106
- Update case-app to 2.1.0-M14 by alexarchambault in #1120
- Update Scala to 3.1.3 by alexarchambault in #1124
- Update jsoniter-scala-core_2.13 to 2.13.32 by scala-steward in #1125
- Update coursier-jvm_2.13, ... to 2.1.0-M6-28-gbad85693f by scala-steward in #1126
- Update libsodiumjni to 0.0.3 by scala-steward in #1127
- Update org.eclipse.jgit to 6.2.0.202206071550-r by scala-steward in #1128
- Update Scala.js to 1.10.1 by scala-steward in #1130
- Update Scala Native to 0.4.5 by alexarchambault in #1133
- Update scala-js-cli to 1.1.1-sc5 by alexarchambault in #1134
- Update jsoniter-scala-core_2.13 to 2.13.33 by scala-steward in #1136
- Update
scalafmt
to 3.5.8 by Gedochao in #1137 - Update cli-options_2.13, cli_2.13, ... to 0.1.7 by scala-steward in #1138
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.8...v0.1.9
v0.1.8
--list-main-classes
option for the run
command
You can pass the option --list-main-classes
to the run
command to list all the available main classes, including
scripts.
$ scala-cli . --list-main-classes
Hello scripts.AnotherScript_sc scripts.Script_sc
Add config
command
The config
sub-command allows to get and set various configuration values, intended for use by
other Scala CLI sub-commands.
This feature has been added in preparation for the publish
command, stay tuned for future announcements.
Added in #1056 by alexarchambault
Prioritise non-script main classes
When trying to run a directory containing scripts and just a single non-script main class, the non-script main class will now be prioritised and run by default.
$ scala-cli .
Running Hello. Also detected script main classes: scripts.AnotherScript_sc, scripts.Script_sc
You can run any one of them by passing option --main-class, i.e. --main-class scripts.AnotherScript_sc
All available main classes can always be listed by passing option --list-main-classes
Hello world
Important bugfixes
Accept latest Scala versions despite stale Scala version listings in cache
Scala CLI uses version listings from Maven Central to check if a Scala version is valid. When new Scala versions are released, users could sometimes have stale version listings in their Coursier cache for a short period of time (the Coursier cache TTL, which is 24 hours by default). This prevented these users to use new Scala versions during that time. To work around that, Scala CLI now tries to re-download version listings when they don't have the requested Scala version. This addresses #1090
Bloop now uses JAVA_HOME
by default
Bloop should now pick up the JDK available in JAVA_HOME
. It was formerly necessary to pass --bloop-jvm system
explicitly. This addresses #1102
The -coverage-out
option now accepts relative paths
Scala CLI now correctly processes relative paths when passed to the -coverage-out
option. Formerly,
the scoverage.coverage
file would not be properly generated when a relative path was passed.
This addresses #1072
Other changes
Documentation PRs
- Improve scripts guide by Gedochao in #1074
- Update installation instructions for Nix by kubukoz in #1082
- Tweak docs by alexarchambault in #1085
- Some typos & rewording on the single-module projects use case page by Baccata in #1089
Fixes
Build and internal changes
- Update scala-cli.sh launcher for 0.1.7 by github-actions in #1076
- Tweaking by alexarchambault in #1087
Full Changelog: https://github.com/VirtusLab/scala-cli/compare/v0.1.7...v0.1.8
Older versions
The release notes for all the past versions of Scala CLI can be viewed on our releases page on GitHub.