Skip to content

Releases: VirtusLab/scala-cli

v1.4.0

27 Jun 14:01
b9412e2
Compare
Choose a tag to compare

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> 

Added by @Gedochao in #2971.

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

Added by @Gedochao in #2955

Features

  • Include test scope in the REPL when the --test flag is passed by @Gedochao in #2971

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

Internal changes

Updates

New Contributors

Full Changelog: v1.3.2...v1.4.0

v1.3.2

24 May 10:43
d905510
Compare
Choose a tag to compare

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

Added by @Gedochao in #2911

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

Fixes

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

  • Fix instant-startup-scala-scripts.md overeager docs-tests by @Gedochao in #2909

Updates

New Contributors

Full Changelog: v1.3.1...v1.3.2

v1.3.1

06 May 22:19
4d529f0
Compare
Choose a tag to compare

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

Added by @Gedochao in #2882

Fixes

  • Adjust TASTY bump warnings to respect overridden Scala version defaults by @Gedochao in #2888
  • Include scala3-staging and scala3-tasty-inspector artifacts when the --with-compiler option is passed in Scala 3 by @Gedochao in #2889

Internal changes

  • Allow to override prog name with a launcher arg by @Gedochao in #2891

Updates

Full Changelog: v1.3.0...v1.3.1

v1.3.0

26 Apr 07:22
692d279
Compare
Choose a tag to compare

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.

Added by @Gedochao in #2862

Fixes

Internal changes

  • Add launcher options allowing to override the default Scala version by @Gedochao in #2860

Updates and maintenance

Full Changelog: v1.2.2...v1.3.0

v1.2.2

11 Apr 08:28
4f98807
Compare
Choose a tag to compare

Fixed the Fatal invariant violated false-positive error coming from Bloop

This small update fixes the Fatal invariant violated error (#2829) that was being thrown by Bloop when running Scala CLI repeatedly with the same sources.

Fixed by @Gedochao & @tgodzik in #2837

Enhancements

  • Log a warning when invalid java properties are being passed by env vars by @Gedochao in #2843

Updates and maintenance

What's Changed

Full Changelog: v1.2.1...v1.2.2

v1.2.1

29 Mar 12:04
94a9ab5
Compare
Choose a tag to compare

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 VirtusLab/scala-js-cli#55.

Fixes

Enhancements

  • Ensure external help options are mentioned in short help where available by @Gedochao in #2808

Internal changes

  • Run integration tests for the latest Scala 3 Next RC by @Gedochao in #2824

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

New Contributors

Full Changelog: v1.2.0...v1.2.1

v1.2.0

07 Mar 08:40
251223e
Compare
Choose a tag to compare

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 VirtusLab/scala-js-cli#47

Fixes

Enhancements

  • Add the ability to remap EsModule imports at link time by @Quafadas in #2737

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

Updates and maintenance

New Contributors

Full Changelog: v1.1.3...v1.2.0

v1.1.3

14 Feb 09:58
f59e4f8
Compare
Choose a tag to compare

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.

scala-cli compile src/semanticdb-example.sc --semanticdb-targetroot ./targetRootDir --semanticdb-sourceroot .

Added by @Gedochao in #2692

Fixes

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

New Contributors

Full Changelog: v1.1.2...v1.1.3

v1.1.2

17 Jan 09:06
0421cd9
Compare
Choose a tag to compare

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 VirtusLab/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
  • in FailedToStartServerException advice, include --power by @SethTisue in #2685

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

Full Changelog: v1.1.1...v1.1.2

v1.1.1

10 Jan 12:42
3d2a670
Compare
Choose a tag to compare

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

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

Updates and maintenance

New Contributors

Full Changelog: v1.1.0...v1.1.1