Skip to content

Releases: VirtusLab/scala-cli

v1.8.5

06 Aug 21:09
3ceeaec
Compare
Choose a tag to compare

Support for Scala 3.7.2

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

scala-cli version
# Scala CLI version: 1.8.5
# Scala version (default): 3.7.2

Added by @Gedochao in #3809

Add props with input paths for non-script inputs

2 new properties have been added, to provide a way to access input paths outside of .sc scripts:

  • scala.sources - full paths of all inputs in the project, separated by java.io.File.pathSeparator
  • scala.source.names - names of all inputs in the project, separated by java.io.File.pathSeparator
//PrintSources.scala
@main def main() = {
  println(sys.props("scala.sources"))
  println(sys.props("scala.source.names"))
}
~/PrintSources.scala
PrintSources.scala

These are meant to be an input type agnostic equivalent for the scriptPath method available in .sc scripts.

Added by @philwalk in #3799

sonatype:snapshots points to the new Sonatype Central snapshots repository

It is no longer necessary to manually add https://central.sonatype.com/repository/maven-snapshots, it is added under the sonatype:snapshots alias (along with the old snapshot repository).
It is also added in all other contexts when snapshots should be used.

//> using repository sonatype:snapshots

Added by @Gedochao in #3797

Scala CLI nightlies are available again

We once again publish Scala CLI nightlies. You can use the newest version under the nightly tag.
As pre-1.8.5 Scala CLI versions do not look for them on the new Sonatype Central snapshots repository, they will not be visible when called from earlier versions.

scala-cli --cli-version nightly version
# Scala CLI version: 1.8.4-24-g8ca6c960b-SNAPSHOT
# Scala version (default): 3.7.2

Note that the new Sonatype Central Portal retains snapshot versions for 90 days, so individual versions will be available to test for a limited time period.

Added by @Gedochao in #3818

Features

  • Automatically add the new Sonatype Central Portal snapshots repository when snapshots are expected to be used by @Gedochao in #3797
  • Adjust Scala CLI nightly version resolution for the new Maven Central Snapshots repository by @Gedochao in #3818
  • provide a way to access paths of source files by @philwalk in #3799
  • Add more logging for publishing by @Gedochao in #3813

Fixes

Build and internal changes

  • Tag tests relying on old snapshots as flaky (or remove them where applicable) by @Gedochao in #3817
  • Add --no-fallback to graalvm native-image configuration by @lbialy in #3820

Updates

New Contributors

Full Changelog: v1.8.4...v1.8.5

v1.8.4

15 Jul 09:45
46a5de6
Compare
Choose a tag to compare

(⚡️ experimental) publish support for the Sonatype Central Portal

This Scala CLI version adds support for publishing artifacts to the Sonatype Central Portal via its OSSRH Staging API.
It is once again possible to publish artifacts to Maven Central with Scala CLI.
Both stable and *-SNAPSHOT versions are handled.
The only configuration change necessary is to migrate the Sonatype namespace in the UI and regenerate credentials to the new Sonatype Central Portal, as per Sonatype instructions

scala-cli publish . --power

Added by @Gedochao in #3774, #3776, #3778, coursier/publish#128 and coursier/publish#127

Better support for the REPL with JDK 24+

When using the REPL with JDK 24 or newer, users should no longer see the warnings about restricted methods of java.lang.System being used.

scala-cli repl --jvm 24
# WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
# WARNING: sun.misc.Unsafe::objectFieldOffset has been called by scala.runtime.LazyVals$ (file:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.7.1/scala3-library_3-3.7.1.jar)
# WARNING: Please consider reporting this to the maintainers of class scala.runtime.LazyVals$
# WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
# Welcome to Scala 3.7.1 (24.0.1, Java OpenJDK 64-Bit Server VM).
# Type in expressions for evaluation. Or try :help.
#            
#
# scala> 

Note that the deprecated method from sun.misc.Unsafe warning is still present, and will only be addressed in Scala 3.8.0.

Added by @Gedochao in #3767

Features

  • publish command with Sonatype Central Portal OSSRH Staging API by @Gedochao in #3774
  • Add support for publishing with Scala CLI to Sonatype Central Portal by @Gedochao in #3776

Fixes

  • Prevent the REPL from warning about restricted java.lang.System API on JDK 24 by @Gedochao in #3767
  • fix for 3725, 3752, 3766 and 3769 by @philwalk in #3726

Documentation changes

Updates

Full Changelog: v1.8.3...v1.8.4

v1.8.3

25 Jun 11:59
13427eb
Compare
Choose a tag to compare

This is a small release which aims to fix issues with publishing Scala CLI on Sonatype Central Portal.

Build and internal changes

  • Add extra logging on Scala CLI artifacts publishing by @Gedochao in #3745
  • [NIT] Refactor publishing by @Gedochao in #3743
  • Ensure publishing to Sonatype runs without parallelism by @Gedochao in #3755
  • Don't use any custom logic when publishing to Sonatype Central by @Gedochao in #3759
  • Print artifacts' version when publishing Scala CLI by @Gedochao in #3760
  • Don't prepend shell scripts for CLI bootstrapped fatJARs by @Gedochao in #3764

Updates

Full Changelog: v1.8.2...v1.8.3

v1.8.2

12 Jun 05:33
6ec4065
Compare
Choose a tag to compare
v1.8.2 Pre-release
Pre-release

Due to technical difficulties, this version is not available on Maven Central and on coursier. If you care about those installation methods, please be patient as we resolve the issue and work on a subsequent release.

Support for Scala Native 0.5.8

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

scala-cli -e 'println("Hello from Scala Native 0.5.8!")' --native
# Compiling project (Scala 3.7.1, Scala Native 0.5.8)
# Compiled project (Scala 3.7.1, Scala Native 0.5.8)
# [info] Linking (multithreadingEnabled=true, disable if not used) (1052 ms)
# [info] Discovered 919 classes and 5640 methods after classloading
# [info] Checking intermediate code (quick) (59 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) (369 ms)
# [info] Discovered 511 classes and 2553 methods after classloading
# [info] Checking intermediate code (quick) (7 ms)
# [info] Discovered 491 classes and 1986 methods after optimization
# [info] Optimizing (debug mode) (519 ms)
# [info] Produced 9 LLVM IR files
# [info] Generating intermediate code (521 ms)
# [info] Compiling to native code (1762 ms)
# [info] Linking with [pthread, dl, m]
# [info] Linking native code (immix gc, none lto) (98 ms)
# [info] Postprocessing (0 ms)
# [info] Total (4379 ms)
# Hello from Scala Native 0.5.8!

Added in #3728

Internal and build changes

Updates

Full Changelog: v1.8.1...v1.8.2

v1.8.1

04 Jun 13:05
eeae7dd
Compare
Choose a tag to compare

Support for Scala 3.7.1

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

scala-cli version
# Scala CLI version: 1.8.1
# Scala version (default): 3.7.1

Added by @Gedochao in #3707

Support for URLs in using file directives

It is now possible to use URLs in using file directives, which allows linking sources from the net.

//> using file https://raw.githubusercontent.com/softwaremill/sttp/refs/heads/master/examples/src/main/scala/sttp/client4/examples/json/GetAndParseJsonCatsEffectCirce.scala

Added during a Scala Tooling Spree by @ivan-klass, @majk-p and @tgodzik in #3681

Features

Fixes

Internal and build changes

  • bugfix: Fix mill script on fish by @tgodzik in #3700
  • Make test-fish-shell, test-hypothetical-sbt-export and bloop-memory-footprint required for publishing by @Gedochao in #3701
  • [NIT] Refactor Scala CLI CI scripts by @Gedochao in #3702
  • Remove the github-dependency-graph CI workflow by @Gedochao in #3703
  • Add more tests for URLs in using file directives by @Gedochao in #3706

Documentation changes

  • Fix Changing Java versions document by @tmrkw1497 in #3697
  • Back port of documentation changes to main by @github-actions in #3699

Updates

New Contributors

Full Changelog: v1.8.0...v1.8.1

v1.8.0

08 May 14:28
1fb78ff
Compare
Choose a tag to compare

Support for Scala 3.7.0 and 3.3.6

This Scala CLI version switches the default Scala version to 3.7.0.
The CLI internals are now built with Scala 3.3.6.

scala-cli version
# Scala CLI version: 1.8.0
# Scala version (default): 3.7.0

Added by @Gedochao in #3661

Support for Scala.js 1.19.0

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

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

Added in #3643 and VirtusLab/scala-js-cli#134

Drop support for Scala <3.3 in runner and test-runner modules

Starting with Scala CLI v1.8.0, the runner and test-runner modules are built with Scala 3.3.6 LTS (on par with other modules built with Scala 3). They used to be built with Scala 3.0.2, as those modules may get added to the project class path when running, respectively, the main scope and tests. This means that if the application is using pre-3.3 Scala 3, TASTy versions will be incompatible.

This is mostly informative, as the change should not be breaking for standard Scala CLI usage, even if an older Scala 3 version is being used. For builds using Scala <3.3, the CLI will automatically fall back to version 1.7.1 of the modules, with an appropriate warning being printed. As the fallback will not be updated in the future, some Scala CLI features might start breaking at some point, as the APIs will stop being fully in sync.

scala-cli -e 'println("Hello")' --runner -S 3.1
# [warn] Scala 3.1.3 is no longer supported by the runner module.
# [warn] Defaulting to a legacy runner module version: 1.7.1.
# [warn] To use the latest runner, upgrade Scala to at least Scala 3.3.
# Compiling project (Scala 3.1.3, JVM (17))
# Compiled project (Scala 3.1.3, JVM (17))
# Hello
scala-cli test . -S 3.2
# [warn] Scala 3.2.2 is no longer supported by the test-runner module.
# [warn] Defaulting to a legacy test-runner module version: 1.7.1.
# [warn] To use the latest test-runner, upgrade Scala to at least 3.3.
# Compiling project (test, Scala 3.2.2, JVM (17))
# Compiled project (test, Scala 3.2.2, JVM (17))
# Test run started
# Test MyTests.foo started
# Hello, world!
# Test MyTests.foo finished, took 0.001 sec
# Test run finished: 0 failed, 0 ignored, 1 total, 0.003s

Realistically, the change is only breaking for apps using those modules directly themselves, either depending on them or using them to run things. In either case, it is recommended to update Scala up to at least 3.3 LTS.

Added by @Gedochao in #3650

Scala CLI now detects and runs multiple test frameworks, rather than just one

When running tests in a project with multiple test frameworks in use, Scala CLI will now attempt to detect and run all of them, rather than just one.

scala-cli test .
# Compiling project (Scala 3.7.0, JVM (23))
# Compiled project (Scala 3.7.0, JVM (23))
# Compiling project (test, Scala 3.7.0, JVM (23))
# Compiled project (test, Scala 3.7.0, JVM (23))
# Munit:
#   + foo 0.007s
# -------------------------------- Running Tests --------------------------------
# + MyTests.foo 1ms  
# Tests: 1, Passed: 1, Failed: 0
# + SimpleSpec
# Hello from zio-test
#   + print hello and assert true
# 1 tests passed. 0 tests failed. 0 tests ignored.
# 
# Executed in 97 ms
# 
# Completed tests
# ScalaTestSpec:
# example
# - should work
# Run completed in 44 milliseconds.
# Total number of tests run: 1
# Suites: completed 1, aborted 0
# Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
# All tests passed.

Additionally, it is now possible to pre-define multiple test frameworks to use (rather than just one, as before).

//> using test.frameworks org.scalatest.tools.Framework munit.Framework custom.CustomFramework

Pre-defining test frameworks may be preferable for bigger projects, as it allows to skip framework detection and run them directly. This is significant particularly for running tests with Scala Native and Scala.js.

Added by @Gedochao in #3653

Features

  • Support the --test flag with the publish & publish local sub-commands by @Gedochao in #3538
  • Misc no-op and/or error handling for the --test command line flag by @Gedochao in #3586
  • Add scala-cli version to the BuildInfo by @yadavan88 in #3617
  • fix sub-command tweaks by @Gedochao in #3646
  • Run all found test frameworks, rather than just one by @Gedochao in #3621
  • Allow to preconfigure multiple test frameworks by @Gedochao in #3653
  • Add support for some missing Scala compiler options & aliases without the need for -O by @Gedochao in #3665
  • Add support for the --repl-quit-after-init REPL option by @Gedochao in #3664

Fixes

  • Fix fmt to format the project.scala configuration file as any other Scala input by @Gedochao in #3609
  • Apply scalafix rules to test scope inputs, too by @Gedochao in #3641

Internal and build changes

  • Cross compile everything on the CI by @Gedochao in #3570
  • Add tests for the current behaviour of --cross by @Gedochao in #3589
  • Run test sub-command integration tests on default JVM settings by @Gedochao in #3592
  • Retry docs' tests on the CI by @Gedochao in #3618
  • Move ScopeOptions to SharedOptions by @Gedochao in #3612
  • Include missing Scala 3.6.* versions in Scala.listAll by @Gedochao in #3652
  • Check formatting with Scala CLI, rather than the scalafmt launcher itself by @Gedochao in #3660

Documentation changes

  • compileOnly option added to the documentation by @yadavan88 in #3600
  • Back port of documentation changes to main by @github-actions in #3601
  • docs: guide for compile only deps by @scarf005 in #3602
  • Back port of documentation changes to main by @github-actions in #3607
  • Add missing using directive reference docs by @Gedochao in #3608
  • Back port of documentation changes to main by @github-actions in #3610
  • Fix formatting in directives' reference docs by @Gedochao in #3611
  • Back port of documentation changes to main by @github-actions in #3616
  • Fixed DEV.md file related to test command by @yadavan88 in #3619
  • Correct doc with --project-version by @joan38 in #3662

Updates

Read more

v1.7.1

18 Mar 07:51
8f67601
Compare
Choose a tag to compare

Support for Scala 3.6.4

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

scala-cli version
# Scala CLI version: 1.7.1
# Scala version (default): 3.6.4

Added by @Gedochao in #3544

Support the --test command line option for doc

It is now possible to generate docs from the test scope with the --test flag.

Added by @Gedochao in #3539

Features

  • Support the --test flag with the doc sub-command by @Gedochao in #3539

Internal and build changes

  • Adjust dependabot configuration for the docs website by @Gedochao in #3555

Documentation changes

Updates

v1.7.0

06 Mar 08:52
f289e12
Compare
Choose a tag to compare

Switch to scalameta/scalafmt images of scalafmt 3.9.1+

Since version 3.9.1 scalafmt ships with native images built with Scala Native. As a result, we are sunsetting https://github.com/virtuslab/scalafmt-native-image and Scala CLI will use the artifacts from https://github.com/scalameta/scalafmt for scalafmt versions >=3.9.1

Note that older Scala CLI versions may still attempt to download a native image from the old repository for the new versions.
We will keep releasing those for a short while to help late upgraders migrate.

scala-cli fmt -F -version
# scalafmt 3.9.2

Added by @Gedochao in #3521

Support the --test command line option for run and package

It is now possible to run a main method from the test scope with the --test flag.

//> using target.scope test
@main def helloFromTestScope(): Unit = println("Hello from the test scope!")
scala-cli run HelloFromTestScope.scala --test --power

# Hello from the test scope!  

Similarly, it is now possible to package the main and test scopes together, using the same --test flag.

scala-cli package HelloFromTestScope.scala --test --power
# # Wrote ./helloFromTestScope, run it with                                       
#  ./helloFromTestScope  
./helloFromTestScope
# Hello from the test scope!  

Keep in mind that the test and main scopes are still separate compilation units, where the test scope depends on the main scope (while the reverse isn't true).

Added by @Gedochao in #3502 and #3519

Detect objects with main class in scripts

Scala CLI now detects objects with a main method in scripts and runs them by default.

object Main {
  def main(args: Array[String]): Unit = println("Hello")
}

Do note that, this is chiefly a convenience feature for migration of old scripts, using the old, legacy scala runner.

If any top-level code is present alongside an object with a main method, the top-level code will be run instead and a warning printed.

object Main {
  def main(args: Array[String]): Unit = println("Hello")
}
println("Top level code says hello")
scala-cli run scriptWithMainObjectAndTopLevel.sc
# [warn]  Script contains objects with main methods and top-level statements, only the latter will be run.                                   
# Compiling project (Scala 3.6.3, JVM (23))
# Compiled project (Scala 3.6.3, JVM (23))
# Top level code says hello

Additionally, cases where multiple main methods are present in the same script are not supported, inidicated by a warning.

object Main {
  def main(args: Array[String]): Unit = println("Hello1")
}

object Main2 {
  def main(args: Array[String]): Unit = println("Hello2")
}

Note that no output is printed in this example:

scala-cli run scriptWithMultipleMainObjects.sc
# [warn]  Only a single main is allowed within scripts. Multiple main classes were found in the script: Main, Main2                          
# Compiling project (Scala 3.6.3, JVM (23))
# Compiled project (Scala 3.6.3, JVM (23))

Finally, main methods defined in this way cannot be chosen via the --main-class command line option directive, and neither will they be printed by the --list-main-methods flag.

Added by @tgodzik in #3479

Support for Scala Native 0.5.7

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

scala-cli -e 'println("Hello from Scala Native 0.5.7!")' --native
# Compiling project (Scala 3.6.3, Scala Native 0.5.7)
# Compiled project (Scala 3.6.3, Scala Native 0.5.7)
# [info] Linking (multithreadingEnabled=true, disable if not used) (1045 ms)
# [info] Discovered 915 classes and 5608 methods after classloading
# [info] Checking intermediate code (quick) (41 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) (352 ms)
# [info] Discovered 498 classes and 2506 methods after classloading
# [info] Checking intermediate code (quick) (9 ms)
# [info] Discovered 477 classes and 1930 methods after optimization
# [info] Optimizing (debug mode) (608 ms)
# [info] Produced 9 LLVM IR files
# [info] Generating intermediate code (650 ms)
# [info] Compiling to native code (1674 ms)
# [info] Linking with [pthread, dl, m]
# [info] Linking native code (immix gc, none lto) (339 ms)
# [info] Postprocessing (0 ms)
# [info] Total (4655 ms)
# Hello from Scala Native 0.5.7!

Added in #3527

Features

  • improvement: Detect objects with main class in scripts by @tgodzik in #3479
  • Add support for running a main method from the test scope by @Gedochao in #3502
  • Support the --test flag with the package sub-command by @Gedochao in #3519

Fixes

Internal and build changes

Documentation changes

Updates

Full Changelog: v1.6.2...v1.7.0

v1.6.2

12 Feb 16:13
72988e3
Compare
Choose a tag to compare

Support for Scala.js 1.18.2

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

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

Added in #3454

Support for Scala 3.3.5

The Scala CLI internals are now built with Scala 3.3.5.

Added by @Gedochao in #3466

Deprecations

  • Add a deprecation warning for using Scala 2.12.4 with Bloop by @Gedochao in #3470

Fixes

  • Remove conflicting Scala 2.13 io.get-coursier:dependency dependency & add a CI check by @Gedochao in #3472

Internal and build changes

Documentation changes

  • Add warning about test files in publish docs by @majk-p in #3486
  • Back port of documentation changes to main by @github-actions in #3487

Updates

New Contributors

Full Changelog: v1.6.1...v1.6.2

v1.6.1

22 Jan 07:56
a41f43b
Compare
Choose a tag to compare

Pass --repl-init-script directly to the Scala REPL

Passing an initialization script to the REPL with --repl-init-script is now allowed directly, rather than after -- or with -O.
The --repl-init-script is a REPL option introduced in Scala 3.6.4, so it's not available for earlier Scala versions.

scala-cli repl -S 3.6.4-RC1 --repl-init-script 'println("Hello")'
# Hello
# Welcome to Scala 3.6.4-RC1 (23.0.1, Java OpenJDK 64-Bit Server VM).
# Type in expressions for evaluation. Or try :help.
#                                                                                                                  
# scala> 

Added by @Gedochao in #3447

Hotfix release

Although Scala CLI 1.6.1 includes a few updates and improvements, it is primarily a hotfix release for version 1.6.0, which due to technical limitations wasn't available on some of our distribution channels.

For extra context refer to:

Features

  • Enable direct usage of --repl-init-script with Scala REPL >= 3.6.4-RC1 by @Gedochao in #3447

Internal and build changes

  • Fix update-packages step of the release job on the CI by @Gedochao in #3446

Updates

Full Changelog: v1.6.0...v1.6.1