Skip to content

Releases: VirtusLab/scala-cli

v1.0.5

25 Oct 13:24
ecf3779
Compare
Choose a tag to compare

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 . --offline

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

Added by @Gedochao in #2450

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

Support for building 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

Added by @keynmol in #2196

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)

Added by @Gedochao in #2465

Other changes

Enhancements

Fixes

Documentation changes

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

Read more

v1.0.4

09 Aug 20:13
6fd1e43
Compare
Choose a tag to compare

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 jdk.unsupported@17.0.6/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.

What's Changed

  • Update scala-cli.sh launcher for 1.0.3 by @github-actions in #2338
  • Add missing note to release notes about rename parameter by @lwronski in #2340
  • Back port of documentation changes to main by @github-actions in #2341
  • Fix - support jvmRunEnvironment request for native launcher of scala-cli by @lwronski in #2342
  • 1.0.4 release notes by @lwronski in #2343

Full Changelog: v1.0.3...v1.0.4

v1.0.3

08 Aug 17:47
83bc7bc
Compare
Choose a tag to compare

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:

  1. Via the using directive:
//> using compileOnly.dep "com.github.plokhotnyuk.jsoniter-scala::jsoniter-scala-macros:2.23.2"
  1. 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

Build and internal changes

Updates and maintenance

Full Changelog: v1.0.2...v1.0.3

v1.0.2

11 Jul 13:29
8bb97d9
Compare
Choose a tag to compare

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 ...

Added by @lwronski in #2267

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

Fixes

Documentation changes

Build and internal changes

Updates and maintenance

New Contributors

Read more

v1.0.1

06 Jun 15:51
83c41ab
Compare
Choose a tag to compare

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 a git 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

Full Changelog: v1.0.0...v1.0.1

v1.0.0

24 May 13:38
Compare
Choose a tag to compare

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!

Added by @lwronski #2140

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 the toolkit dependency to the main scope and the toolkit-test dependency to the test scope
  • if you place e.g. //> using toolkit latest within a test scope file, both toolkit and toolkit-test will be limited to the test scope only
  • inserting e.g. //> using test.toolkit latest anywhere in the project will add both toolkit and toolkit-test to the test scope only

This convention is encouraged for other toolkit-like libraries as well.

Added by @Gedochao #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 #2136

Other changes

  • Add alias for snapshots repository in Maven by @lwronski #2125
  • Bump typelevel-toolkit to 0.0.11, configure toolkit-test by @armanbilge #2135
  • Fix updating toolkit dependencies by @Gedochao #2138
  • Improve directive parsing errors & special-case toolkit directive version parsing by @Gedochao #2133
  • Fix determining position for value in directive without quotes by @lwronski #2141

Fixes

Documentation changes

Build and internal changes

Updates and maintenance

  • Update scala-cli.sh launcher for 1.0.0-RC2 by @github-actions #2105
  • Update org.eclipse.jgit to 6.5.0.202303070854-r by @scala-steward #2090

New Contributors

Full Changelog: v1.0.0-RC2...v1.0.0

v1.0.0-RC2

09 May 20:02
a38c525
Compare
Choose a tag to compare

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"

Added by @lwronski in #2053.

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"

Added by @Gedochao in #2046

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

Added by @tgodzik in #2076

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

Added by @lwronski in #1990

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:${.}"

Added by @lwronski in #2040

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

Publishing changes

Fixes

Documentation changes

Build and internal changes

Read more

v1.0.0-RC1

04 Apr 06:06
5c974ce
Compare
Choose a tag to compare

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

Added by @Gedochao in #1920

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.

Added by @Gedochao in #1953

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 by @tgodzik in #1932

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 by @lwronski in #1961

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")

Added by @lwronski in #1964

Other changes

Publishing changes

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

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

Updates and maintenance

New Contributors

Full Changelog: v0.2.1...v1.0.0-RC1

v0.2.1

16 Mar 10:48
4be1b56
Compare
Choose a tag to compare

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.

Added by @Gedochao in #1900

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.

Added by @lwronski in #1878

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.

Added by @Gedochao in #1910

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

SIP-related changes

  • Add 'dependency' and 'dependencies' alias for using directive by @MaciejG604 in #1903

Documentation updates

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

v0.2.0

22 Feb 07:20
e839a33
Compare
Choose a tag to compare

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"

Renamed by @lwronski in #1827

Improved readability of help messages for commands

The help messages are now shorter and more concise, making it easier to quickly get an overview of the available options for a command.

To improve readability, some options and detailed messages are now only visible after showing the full help by passing --full-help.

Added by @Gedochao in #1872

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.

Screen Recording 2023-02-21 at 12 22 15

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.

Remove by @lwronski in #1867

Other changes

SIP-related changes

  • Add a warning for the -run option of the legacy scala runner, instead of failing by @Gedochao in #1801
  • Add warnings for the deprecated -Yscriptrunner legacy scala runner option instead of passing it to scalac by @Gedochao in #1804
  • Filter out restricted & experimental options from SIP 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

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 if testFramework 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

Read more