Releases: VirtusLab/scala-cli
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 . --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
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
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 ...
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 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
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: 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](...
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: 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 #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
- Fix line conversion logic by simplifying topWrapperLen to line count of top wrapper by @MaciejG604 #2101
- Fix test watch infinite loop by @MaciejG604 #2113
- Fix flaky completions for
zsh
by @Jasper-M #2118 - Fix - install certificates for java by @lwronski #2123
- Fix the
--source-jar
option & add correspondingusing
directives by @Gedochao #2120
Documentation changes
- Add docs for bootstrapped standalone fat JAR by @lwronski #2122
- Add developer docs on modifying
reflect-config.json
by @Gedochao #2114
Build and internal changes
- Update release procedure - update also v1 tag by @lwronski #2107
- NIT Refactor test scope directives by @Gedochao #2083
- Add main class to jar manifest in assembly by @romanowski #2124
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
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 Preproc...
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
- Support ssh in GitHub repo org&name extraction by @KuceraMartin in #1938
- Comply with optional password in
scala-cli-signing
by @MaciejG604 in #1982
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
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: 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"
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
.
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
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](https://github.com/VirtusLab/scala-cli/pu...