Releases: VirtusLab/scala-cli
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...
v0.1.20
Add support for Scala Toolkit
Scala CLI now has support for Scala Toolkit.
Scala Toolkit is an ongoing effort by Scala Center and VirtusLab to compose a set of approachable libraries to solve everyday problems.
It is currently in its pre-release phase and includes the following libraries:
- MUnit for testing;
- Sttp for HTTP client;
- UPickle/UJson for reading, writing and operating on JSONs;
- OS-Lib for operating on files and the operating system.
You can add it to your build from the command line with the --with-toolkit
option.
scala-cli . --with-toolkit latest
There's also an appropriate using
directive.
//> using toolkit "0.1.4"
Scala CLI is built with Scala 3.2.2
We now rely on Scala 3.2.2
as the default internal Scala version used to build the project.
Added by @lwronski and @Gedochao in #1772
Removal of the about
and doctor
sub-commands
The about
command has been removed, its features merged back to the version
command.
As a result, the version
command will now check if your locally installed Scala CLI is up-to-date.
It is possible to skip the check with the --offline
option, or when printing raw CLI or default Scala
versions with --cli-version
and --scala-version
, respectively.
scala-cli version --offline
# Scala CLI version: 0.1.20
# Scala version (default): 3.2.2
Similarly, the doctor
sub-command has been removed, with its past and previously planned functionalities to be delivered
in a more interactive manner in the future.
The Scala CLI aarch64/arm64
binary is now available via sdkman
You can now get the platform-appropriate Scala CLI binary on aarch64/arm64
architecture via sdkman
.
aarch64/arm64
artifact with the launcher script
The scala-cli.sh
launcher script now correctly downloads the aarch64/arm64
artifact on the appropriate architecture.
Run a .jar
file as a regular input
JARs can now be run just like any other input, without the need of passing the -cp
option.
scala-cli Hello.jar
# Hello
Java properties without the need for --java-prop
The --java-prop
option can be skipped when passing Java properties to Scala CLI now.
scala-cli Hello.scala -Dfoo=bar
Docker packaging with using
directives
It is now possible to configure packaging into a docker image via using
directives.
//> using packaging.dockerFrom "openjdk:11"
//> using packaging.dockerImageTag "1.0.0"
//> using packaging.dockerImageRegistry "virtuslab"
//> using packaging.dockerImageRepository "scala-cli"
Pass GraalVM args via a using
directive
It is now possible to pass args to GraalVM via the following using
directive:
//> using packaging.graalvmArgs "--no-fallback", "--enable-url-protocols=http,https"
Other changes
SIP-related changes
- Remove irrelevant options from
version
help message by @lwronski in #1737 - Include launcher options in the help for the default and
help
sub-commands by @Gedochao in #1725 - Remove suffix
.aux
from progName when installed by cs by @lwronski in #1736 - Don't fail in case of connection errors in the version sub-command by @Gedochao in #1760
- Set workspace dir to
os.tmp.dir
for virtual sources by @lwronski in #1771 - Add support for deprecated Scala
2.13.x
-specificscala
runner options by @Gedochao in #1774 - Add support for the
-with-compiler
runner option by @Gedochao in #1780
Fixes
- Take into account interactively picked options when caching binaries by @alexarchambault in #1701
- Erase things in working dir in publish by @alexarchambault in #1715
- Improve formatting of generated Mill project by @lolgab in #1677
- Restart Bloop server if it exited by @alexarchambault in #1716
- Add CLI option for suppressing the warning about directives in multiple files by @MaciejG604 in #1754
- Add a global configuration for suppressing the warning about directives in multiple files by @MaciejG604 in #1779
- Set page size for aarch64 Linux binaries to 64k by @mkurz in #1726
Build and internal changes
- Tweaking by @alexarchambault in #1711
- Address some native-image warnings by @alexarchambault in #1719
- Do not generate Linux aarch64 binaries from PRs by @alexarchambault in #1720
- Derive using directives handlers from case classes by @alexarchambault in #1637
- Don't run commands upon HelpTests instantiation by @alexarchambault in #1762
Documentation updates
- Add test-only cookbook by @lwronski in #1718
- Fixing minor typos and some wordsmithing. by @medale in #1731
- Back port of documentation changes to main by @github-actions in #1735
- Explain the differences in using shebang vs scala-cli directly in script by @lwronski in #1740
- Add instruction for Intellij JVM version by @MaciejG604 in #1773
- Fix a broken link by @xerial and @lwronski in #1777
Updates & maintenance
- Update svm to 22.3.0 by @scala-steward in #1689
- Update scala-cli.sh launcher for 0.1.19 by @github-actions in #1707
- Bump VirtusLab/scala-cli-setup from 0.1.18 to 0.1.19 by @dependabot in #1709
- Update Bloop to 1.5.6-sc-1 by @lwronski in #1704
- Update trees_2.13 to 4.7.1 by @scala-steward in #1717
- Update coursier-jvm_2.13, ... to 2.1.0-RC4 by @scala-steward in #1723
- Bump uraimo/run-on-arch-action from 2.3.0 to 2.5.0 by @dependabot in #1734
- Update jsoniter-scala-core_2.13, ... to 2.20.0 by @scala-steward in #1732
- Update jsoniter-scala-core_2.13, ... to 2.20.1 by @scala-steward in #1741
- Update scalafmt-cli_2.13, scalafmt-core to 3.6.1 by @scala-steward in #1742
- Update core_2.13 to 3.8.6 by @scala-steward in #1746
- Update libdaemon to 0.0.11 by @scala-steward in #1759
- Update jsoniter-scala-core_2.13, ... to 2.20.2 by @scala-steward in #1757
- Update core_2.13 to 3.8.7 by @scala-steward in #1758
- Update bloop core to 1.5.6-sc-2 by @lwronski in #1761
- Update core_2.13 to 3.8.8 by @scala-steward in #1770
- Update ammonite to 2.5.6 by @scala-steward in #1769
- Update jsoniter-scala-core_2.13, ... to 2.20.3 by @scala-steward in #1776
- Update amm to 2.5.6-1-f8bff243 by @lwronski in #1778
New Contributors
- @mkurz made their first contribution in #1726
- @medale made their first contribution in #1731
- @MaciejG604 made their first contribution in #1773
- @xerial made their first contribution in #1777
Full Changelog: v0.1.19...v0.1.20
v0.1.19
What's Changed
The Linux aarch64
native launcher is here! (experimental)
We are happy to announce that there is a new dedicated launcher for the Linux Aarch64. You can find it here.
Fix workspace/reload
for Intellij IDEA
Dependencies (and other configurations) from using
directives should now always be picked up after a BSP project reload.
Screen.Recording.2022-12-13.at.13.34.17.mov
shebang
headers in Markdown
The shebang
headers in scala
code blocks inside a markdown input are always ignored.
# Scala with `shebang`
A sample code block with the `shebang` header.
```scala
#!/usr/bin/env -S scala-cli shebang
println("Hello world")
```
Export Scala compiler plugins to Mill projects
It is now possible to export scalac
compiler plugins from a Scala CLI project to Mill with the export
sub-command.
Added by @ carlosedp in #1626
Other changes
SIP Changes
- Fix the order of help command groups for the default help by @Gedochao in #1697
- Adjust SIP help output & ensure
ScalaSipTests
are run on Windows by @Gedochao in #1695 - Add warnings for
-save
&-nosave
legacyscala
runner options instead of failing by @Gedochao in #1679
Fixes
- Suggest to update only to stable version by @lwronski in #1634
- Fix - Skip checking file order by @lwronski in #1696
- fix if else in mill.bat by @MFujarewicz in #1661
- Add repositories from build options when validating scala versions by @lwronski in #1630
- Fix using directives not working with the shebang line in
.scala
files by @Gedochao in #1639 - Don't clear compilation output dir by @clutroth in #1660
Documentation updates
- Decompose the README & add a contributing guide by @Gedochao in #1650
- Improve IDE support docs by @Gedochao in #1684
Build and internal changes
- Use snapshot repo to download stubs by @lwronski in #1693
- Temporarily rollback CI to
ubuntu-20.04
by @Gedochao in #1640 - Fix - merge extra repos with resolve.repositories by @lwronski in #1643
- Use Mill directory convention in mill project by @lolgab in #1676
Updates & maintenance
- Update coursier-jvm_2.13, ... to 2.1.0-RC3 by @scala-steward in #1688
- Update coursier-jvm_2.13, ... to 2.1.0-RC3-1 by @scala-steward in #1702
- Update slf4j-nop to 2.0.6 by @scala-steward in #1691
- Ignore
jsoniter
updates for JDK 8 by @lwronski in #1694 - Update trees_2.13 to 4.7.0 by @scala-steward in #1690
- Update jsoniter-scala-core_2.13 to 2.19.1 by @scala-steward in #1674
- Update jsoniter-scala-core_2.13 to 2.19.0 by @scala-steward in #1672
- Update os-lib to 0.9.0 by @scala-steward in #1653
- Update scala-collection-compat to 2.9.0 by @scala-steward in #1657
- Update core_2.13 to 3.8.5 by @scala-steward in #1655
- Update pprint to 0.8.1 by @scala-steward in #1654
- Update mill-main to 0.10.10 by @scala-steward in #1652
- Update org.eclipse.jgit to 6.4.0.202211300538-r by @scala-steward in #1656
- Update jsoniter-scala-core_2.13 to 2.18.1 by @scala-steward in #1651
- Update slf4j-nop to 2.0.5 by @scala-steward in #1658
- Bump VirtusLab/scala-cli-setup from 0.1.17 to 0.1.18 by @dependabot in #1644
- Update scala-cli.sh launcher for 0.1.18 by @github-actions in #1624
- Update using_directives to 0.0.10 by @scala-steward in #1692
- Bumped up com.lihaoyi::os-lib version to 0.9.0 by @pingu1m in #1649
New Contributors
- @pingu1m made their first contribution in #1649
- @clutroth made their first contribution in #1660
- @MFujarewicz made their first contribution in #1661
Full Changelog: v0.1.18...v0.1.19
v0.1.18
Filter tests with --test-only
It is now possible to filter test suites with the --test-only
option.
//> using lib "org.scalameta::munit::1.0.0-M7"
package tests.only
class Tests extends munit.FunSuite {
test("bar") {
assert(2 + 2 == 5)
}
test("foo") {
assert(2 + 3 == 5)
}
test("foo-again") {
assert(2 + 3 == 5)
}
}
package tests
class HelloTests extends munit.FunSuite {
test("hello") {
assert(2 + 2 == 4)
}
}
scala-cli test BarTests.scala HelloTests.scala --test-only 'tests.only*'
# tests.only.Tests:
# ==> X tests.only.Tests.bar 0.037s munit.FailException: ~/project/BarTests.scala:5 assertion failed
# 4: test("bar") {
# 5: assert(2 + 2 == 5)
# 6: }
# at munit.FunSuite.assert(FunSuite.scala:11)
# at tests.only.Tests.$init$$$anonfun$1(BarTests.scala:5)
# at tests.only.Tests.$init$$$anonfun$adapted$1(BarTests.scala:6)
# + foo 0.004s
# + foo-again 0.001s
Filtering particular tests by name requires passing args to the test framework.
For example, with munit
:
scala-cli test BarTests.scala HelloTests.scala --test-only 'tests.only*' -- '*foo*'
# tests.only.Tests:
# + foo 0.032s
# + foo-again 0.001s
Accept authenticated proxy params via Scala CLI config
If you can only download artifacts through an authenticated proxy, it is now possible to configure it
with the config
subcommand.
scala-cli config httpProxy.address https://proxy.company.com
scala-cli config httpProxy.user _encoded_user_
scala-cli config httpProxy.password _encoded_password_
Replace _encoded_user_
and _encoded_password_
by your actual user and password, following
the password option format. They should typically look like env:ENV_VAR_NAME
, file:/path/to/file
, or command:command to run
.
Added by @alexarchambault in #1593
Support for running Markdown sources from zipped archives and gists
It is now possible to run .md
sources inside a .zip
archive.
Same as with directories, .md
sources inside zipped archives are ignored by default, unless
the --enable-markdown
option is passed.
scala-cli archive-with-markdown.zip --enable-markdown
This also enables running Markdown sources fom GitHub gists, as those are downloaded by Scala CLI as zipped archives.
scala-cli https://gist.github.com/Gedochao/6415211eeb8ca4d8d6db123f83f0f839 --enable-markdown
It is also possible to point Scala CLI to a .md
file with a direct URL.
scala-cli https://gist.githubusercontent.com/Gedochao/6415211eeb8ca4d8d6db123f83f0f839/raw/4c5ce7593e19f1390555221e0d076f4b02f4b4fd/example.md
Support for running piped Markdown sources
Instead of passing paths to your Markdown sources, you can also pipe your code via standard input:
echo '# Example Snippet
```scala
println("Hello")
```' | scala-cli _.md
Support for running Markdown snippets
It is now possible to pass Markdown code as a snippet directly from the command line.
scala-cli run --markdown-snippet '# Markdown snippet
with a code block
```scala
println("Hello")
```'
Customize exported Mill project name
It is now possible to pass the desired name of your Mill project to the export
sub-command
with the --project
option.
scala-cli export . --mill -o mill-proj --project project-name
Added by @carlosedp in #1563
Export Scala compiler options to Mill projects
It is now possible to export scalac
options from a Scala CLI project to Mill with the export
sub-command.
Other changes
Fixes
- Fix overriding settings from tests by @alexarchambault in #1566
- Print compilation failed in watch mode too in test command by @alexarchambault in #1548
- Fix error message when running JVM launcher from Java 8 by @alexarchambault in #1575
- Fix
using
directives for Markdown inputs by @Gedochao in #1598 - Fix - clean up only homebrew-scala-experimental directory by @lwronski in #1615
- Warn users when pushing to Sonatype with missing credentials or params by @alexarchambault in #1545
- Warning for multiple files with using directives by @wleczny in #1591
- Make package --python work by @alexarchambault in #1531
- Better revolver output by @alexarchambault in #1614
- Make
PackageTestsDefault.reuse run native binary
more robust by @lwronski in #1621
Documentation updates
- Add some explanations on implicit sub-commands in
-help
by @Gedochao in #1587 - Runner specification by @romanowski in #1445
- Install documentation update by @wleczny in #1595
- Document recent features & changes affecting working with Markdown inputs by @Gedochao in #1606
- Improve docs coverage with
sclicheck
by @Gedochao in #1612 - Reduce ignore tags in the docs snippets by @Gedochao in #1617
Build and internal changes
- Remove superfluous annotation by @alexarchambault in #1567
- Decompose & refactor
Inputs
by @Gedochao in #1565 - Disable create PGP key test on Windows CI by @alexarchambault in #1588
- Switch to Scala 3-based case-app by @alexarchambault in #1568
- Remove cli-options module by @alexarchambault in #1552
- Enable to force using jvm signing launcher for native launcher of scala-cli by @lwronski in #1597
- Run warm up test before running default tests by @lwronski in #1599
- Make DefaultTests more robust by @alexarchambault in #1613
Updates & maintenance
- Update scala-cli.sh launcher for 0.1.17 by @github-actions in #1564
- Update zip-input-stream to 0.1.1 by @scala-steward in #1573
- Update coursier-jvm_2.13, ... to 2.1.0-RC1 by @scala-steward in #1572
- Update mill-main to 0.10.9 by @scala-steward in #1571
- Update test-runner, tools to 0.4.8 by @scala-steward in #1574
- Update case-app_2.13 to 2.1.0-M21 by @scala-steward in #1570
- Bump VirtusLab/scala-cli-setup from 0.1.16 to 0.1.17 by @dependabot in #1579
- Bump Ammonite to 2.5.5-17-df243e14 & Scala to 3.2.1 by @Gedochao in #1586
- Update scala-cli-signing to 0.1.13 by @alexarchambault in #1569
- Update coursier-jvm_2.13, ... to 2.1.0-RC2 by @scala-steward in #1590
- Update scalajs-sbt-test-adapter_2.13 to 1.11.0 by @scala-steward in #1477
- Update slf4j-nop to 2.0.4 by @scala-steward in #1596
- Update jsoniter-scala-core_2.13 to 2.18.0 by @scala-steward in #1608
- Update test-runner, tools to 0.4.9 by @scala-steward in #1610
- Update Bloop to 1.5.4-sc-4 by @alexarchambault in #1622
- Update scalajs-sbt-test-adapter_2.13 to 1.12.0 by @scala-steward in #1609
New Contributors
- @carlosedp made their first contribution in #1563
Full Changelog: v0.1.17...v0.1.18
v0.1.17
Enhancements
Set the default name for the project's workspace root file as project.scala
.
There were multiple discussions about what the name should and it seems the winning vote was on project.scala
instead of project.settings.scala
.
To see how exactly is the root directory resolved, see this document.
SDKMAN and Homebrew support installation of Scala CLI for M1
To install Scala CLI via SDKMAN, run the following command from the command line:
sdk install scalacli
and to install Scala CLI via homebrew:
brew install Virtuslab/scala-cli/scala-cli
Added by @wleczny in #1505 and #1497
Specifying the --jvm
option via using directives
The --jvm
option can now be added via using directives, like
//> using jvm "adopt:11"
Accept more scalac
options without escaping
Scala CLI now accepts options such as -rewrite
, -new-syntax
, -old-syntax
, -source:<target>
, -indent
and -no-indent
, without requiring them to be escaped by -O
.
Enable python
support via using directives
The --python
option can now be enabled via a using directive, like
//> using python
Added by @alexarchambault in #1492
Other changes
Work in Progress
Publish
- Various config command tweaks / fixes by @alexarchambault in #1460
- Accept email via --email when creating a PGP key in config command by @alexarchambault in #1482
- Make publish --python work by @alexarchambault in #1494
- Add repositories.credentials config key by @alexarchambault in #1466
- Check for missing org and version at the same time in publish by @alexarchambault in #1534
- Rename some publish config keys by @alexarchambault in #1532
- Add publish.credentials config key, use it to publish by @alexarchambault in #1533
Spark
- Accept spark-submit arguments on the command-line by @alexarchambault in #1455
Markdown
Fixes
- Fix generating pkg package for M1 by @lwronski in #1461
- Return exit code 1 when build fails for test by @lwronski in #1518
- Fix the
nativeEmbedResources
using directive by @Gedochao in #1525 - Fix completions when install by cs - strip suffix .aux by @lwronski in #1561
Build and internal changes
- Automate deploy of scala-experimental brew formula by @wleczny in #1530
- Decompose RunTestDefinitions by @Gedochao in #1529
- Add some simple tests for running
.md
sources by @Gedochao in #1527 - Run doc tests from munit test suites by @alexarchambault in #1435
- Minor refacto around build options stuff by @alexarchambault in #1488
- No need to use os.ProcessOutput.ReadLines in test by @alexarchambault in #1491
- Enforce logging options for all scala commands by @Gedochao in #1499
- Tweak documentation verification tests by @Gedochao in #1504
- Support
jvmRunEnvironment
andjvmTestEnvironment
for BSP by @Gedochao in #1519 - Downgrade Scala version in 'scala-cli repl --amm' if needed by @alexarchambault in #1493
- Clean up references to scala-cli in SIP mode by @lwronski in #1547
- Move commands under distinct namespaces by @lwronski in #1558
Documentation / help updates
- Tweak / fix publish messages by @alexarchambault in #1535
- Merge documentation of installing scala-cli on MacOs and MacOs/M1 by @wleczny in #1507
- Improve the basics doc by @Gedochao in #1513
- Fix a typo in the
--server
option reference doc by @Gedochao in #1521 - Improve the docs on using Scala compiler options by @Gedochao in #1503
- Add help for repl, scalafmt and scaladoc by @wleczny in #1487
- remove paragraph about bug for coursier install by @bishabosha in #1485
- Tell about pressing Enter in watch message by @alexarchambault in #1465
- Update the recommened installation options for SiP Scala by @tgodzik in #1547
- Add default values to help messages by @wleczny in #1555
Updates / maintainance
- Update jsoniter-scala-core_2.13 to 2.17.9 by @scala-steward in #1544
- Bump docusaurus to 2.20 and other docs deps by @lwronski in #1540
- Update jsoniter-scala-core_2.13 to 2.17.8 by @scala-steward in #1537
- Update cli-options_2.13, cli_2.13, ... to 0.1.11 by @scala-steward in #1538
- Update case-app_2.13 to 2.1.0-M19 by @scala-steward in #1536
- Bump coursier/setup-action from 1.2.1 to 1.3.0 by @dependabot in #1496
- Update scala-cli.sh launcher for 0.1.16 by @github-actions in #1458
- Bump VirtusLab/scala-cli-setup from 0.1.15 to 0.1.16 by @dependabot in #1462
- Update expecty to 0.16.0 by @scala-steward in #1467
- Update jsoniter-scala-core_2.13 to 2.17.5 by @scala-steward in #1470
- Update mill-main to 0.10.8 by @scala-steward in #1472
- Update pprint to 0.8.0 by @scala-steward in #1473
- Update core_2.13 to 3.8.3 by @scala-steward in #1474
- Update publish_2.13 to 0.1.3 by @scala-steward in #1475
- Update trees_2.13 to 4.6.0 by @scala-steward in #1478
- Update slf4j-nop to 2.0.3 by @scala-steward in #1479
- Update asm to 9.4 by @scala-steward in #1476
- Update using_directives to 0.0.9 by @scala-steward in #1480
- Update fansi to 0.4.0 by @scala-steward in #1471
- Update case-app_2.13 to 2.1.0-M18 by @scala-steward in #1468
- Bump webfactory/ssh-agent from 0.5.4 to 0.7.0 by @dependabot in #1495
- Update jsoniter-scala-core_2.13 to 2.17.6 by @scala-steward in #1498
- Update coursier to 2.1.0-M7-39-gb8f3d7532 by @alexarchambault in #1520
New Contributors
- @bishabosha made their first contribution in #1485
Full Changelog: v0.1.16...v0.1.17
v0.1.16
This release consists mainly of updates, fixes, and various enhancements of existing features.
Enhancements
Specifying javac options via using directives
javac options can now be added via using directives, like
//> using javacOpt "source", "1.8", "target", "1.8"
Pressing enter in watch mode proceeds to run / compile / test / … again
In watch mode (using the -w
or --watch
option), pressing Enter when Scala CLI is watching for changes makes it run again what it's supposed to be doing (compiling, running, running tests, or packaging, etc.) This is inspired by Mill's behaviour in watch mode, which supports the same feature.
Added by @alexarchambault in #1451
Installation via Scoop on Windows
Scala CLI can now be installed via Scoop on Windows, with a command such as
scoop install scala-cli
Added by @nightscape in #1416, thanks to him!
Actionable diagnostics in Metals
Scala CLI should now send text edit suggestions with some of its diagnostics, via BSP, so that editors
can suggest those edits to users. This should work in upcoming versions of Metals in particular.
Other
- Add
--scalapy-version
option by @alexarchambault in #1397
Fixes
Fixes in Scala Native binaries caching
When running a sequence of commands such as
$ scala-cli run --native .
$ scala-cli package --native . -o my-app
Scala CLI should cache a Scala Native binary during the first command, so that the second command can just re-use it, rather than generating a binary again. This also fixes the re-use of compilation artifacts between both commands, so that the Scala CLI project isn't re-compiled during the second command either.
Fixed by @alexarchambault in #1406
Accept more scalac options without escaping
Scala CLI now accepts options such as -release
, -encoding
, -color
, -feature
, -deprecation
and -nowarn
, without requiring them to be escaped by -O
. It also accepts --scalac-verbose
, which is equivalent to -O -verbose
(increases scalac verbosity). Lastly, it warns when -release
and / or -target:<target>
are inconsistent with --jvm
.
Fix --java-option
and --javac-option
handling in package
sub-command
--java-option
and --javac-option
should now be accepted and handled properly in the package
sub-command.
Fix wrong file name when publising Scala.js artifacts locally
The publish local
sub-command used to publish Scala.js artifacts with a malformed suffix. This is now fixed.
Fix spurious stack traces in the publish
and publish local
sub-commands
The publish
and publish local
commands could print spurious stack traces when run with non-default locales, using native Scala CLI binaries. This is now fixed.
Fixed by @romanowski in #1423
Make run --python --native
work from Python virtualenv
Using both --native
and --python
in the run
sub-command should work fine from Python virtualenv.
Fixed by @kiendang in #1399, thanks to him!
Documentation / help updates
- Dump scala 2 version in docs by @lwronski in #1408
- Ensure the the
repl
& default sub-commands respect group help options by @Gedochao in #1417 - Remove stray
_
typo by @armanbilge in #1385 - Add docs on how to install scala-cli for M1 by @lwronski in #1431
- Debugging cookbook by @wleczny in #1441
Updates / maintainance
- Update scala-cli.sh launcher for 0.1.15 by @github-actions in #1401
- Revert scalafmt fix by @lwronski in #1402
- Bump respective Scala versions to
2.12.17
&2.13.9
and Ammonite to2.5.4-33-0af04a5b
by @Gedochao in #1405 - Turn off running tests in PR for M1 runner by @lwronski in #1403
- Bump VirtusLab/scala-cli-setup from 0.1.14.1 to 0.1.15 by @dependabot in #1414
- Bump coursier/setup-action from f883d08305acbc28e5e5363bf5ec086397627021 to 1.2.1 by @dependabot in #1415
- Tweak the release procedure by @Gedochao in #1426
- Update case-app_2.13 to 2.1.0-M17 & scala-cli-signing to v0.1.10 by @lwronski in #1427
- Automate choco package deploy by @wleczny in #1412
- Generate pkg package for m1 by @lwronski in #1410
- Re-enable gif tests by @alexarchambault in #1436
- Bump Scala 2.13.x to 2.13.10 & Ammonite to 2.5.5 by @Gedochao in #1437
- Remove mill-scala-cli stuff from build by @alexarchambault in #1433
- Add support for BSP's
buildTarget/outputPaths
and update bsp4j to 2… by @lwronski in #1439 - Update bsp4j to 2.1.0-M3 by @lwronski in #1444
- Update scala-packager to 0.1.29 and hardcode upgradeCodeGuid by @lwronski in #1446
- Refactor
ScalaCommand
to enforce respecting help options by @Gedochao in #1440 - Address compilation warnings by @alexarchambault in #1452
- Update coursier to 2.1.0-M7 by @alexarchambault in #1447
- Update bloop to 1.5.4-sc-3 by @alexarchambault in #1454
New Contributors
- @nightscape made their first contribution in #1416
- @kiendang made their first contribution in #1399
Full Changelog: v0.1.15...v0.1.16
v0.1.15
The M1 native launcher is here! (experimental)
We are happy to announce that there is a new dedicated launcher for M1 users. You can find it here.
Please note that the package
sub-command is unstable for this launcher.
--python
option for repl
sub-command (experimental)
Passing the --python
option allows using ScalaPy
with the repl
sub-command:
▶ scala-cli --python
Welcome to Scala 3.2.0 (17.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> import me.shadaj.scalapy.py
scala> py.Dynamic.global.range(1, 4)
val res0: me.shadaj.scalapy.py.Dynamic = range(1, 4)
Added in #1336 by @alexarchambault
-d
, -classpath
and compile
sub-command's --output
options changes
To be backward compatible with the scala
command, some changes have been made to the following options:
- The
compile
sub-command's--output
option has been renamed to--compilation-output
. This option is now also available from therun
andpackage
sub-commands.
▶ scala-cli compile Hello.scala --compilation-output out
▶ scala-cli --main-class Hello -classpath out
Hello
- The
-d
option is no longer an alias for--dependency
, but for--compilation-output
.-O -d -O path/to/compilation/output
now defaults to-d path/to/compilation/output
.
▶ scala-cli compile Hello.scala -d out
▶ scala-cli --main-class Hello -classpath out
Hello
- The old
--classpath
option has been renamed to--print-classpath
.--classpath
,--class-path
and-classpath
options are now aliases for the--extra jars
option.-O -classpath -O path/to/classpath
now defaults to--extra-jars path/to/classpath
.
▶ scala-cli compile --print-classpath Hello.scala
# ~/Projects/debug-test/.scala-build/project_103be31561_103be31561-7a1ed8dde0/classes/main:~/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.2.0/scala3-library_3-3.2.0.jar:~/Library/Caches/ScalaCli/local-repo/v0.1.15/org.virtuslab.scala-cli/runner_3/0.1.15/jars/runner_3.jar:~/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.8/scala-library-2.13.8.jar
Make inputs optional when -classpath
and --main-class
are passed
The following changes have been made to improve backward compatibility with the scala
command:
- Passing the
--main-class
option along with-classpath
to the default command now defaults torun
instead ofrepl
:
▶ scala-cli --main-class Hello -classpath out
Hello
- If the
run
sub-command is passed explicitly, it's sufficient to have a main class on the classpath (inputs aren't necessary then):
▶ scala-cli compile Hello.scala -d out
▶ scala-cli run -classpath out
Hello
Debugging with the run
and test
sub-commands
It is now possible to debug code ran by run
and test
sub-commands:
▶ scala-cli Main.scala --debug
Listening for transport dt_socket at address: 5005
Hello
This addresses #1212
--platform
option
This option can be used to choose the platform, which should be used to compile and run the application.
▶ scala-cli Main.scala --platform js
Hello
Note that --platform js
is an alias for --js
and --platform native
is an alias for --native
.
This addresses #1214
Other changes
Fixes
- Ensure directories are created recursively when the
package
sub-command is called by @Gedochao in #1371 - Fix calculation of Scala version and turn off the
-release
flag for 2.12.x < 2.12.5 by @Gedochao in #1377 - Fix finding main classes in external jars by @Gedochao in #1380
- Fix Js split style SmallModulesFor in pure JVM by @lwronski in #1394
Build and internal changes
- Remove mill-scalafix customization by @alexarchambault in #1360
- Split config db stuff to a separate config module by @alexarchambault in #1367
- Detect sip when installed by coursier by @lwronski in #1368
- Create empty class to enforce resolving ivy deps by mill for dummy modules by @lwronski in #1374
- Use millw launcher instead of running mill by cs by @lwronski in #1375
- Add --debug option for integration tests by @wleczny in #1378
- NIT ScalaVersionUtil refactor by @Gedochao in #1384
- Make config module compatible with Java 8 by @alexarchambault in #1387
- Add HTTP proxy-related keys in config module by @alexarchambault in #1388
- Add repositories-related keys in config module by @alexarchambault in #1395
Updates
- Update scala-cli.sh launcher for 0.1.14 by @github-actions in #1362
- Update jsoniter-scala-core_2.13 to 2.17.3 by @scala-steward in #1364
- Update core_2.13 to 3.8.0 by @scala-steward in #1365
- Bump VirtusLab/scala-cli-setup from 0.1.13 to 0.1.14.1 by @dependabot in #1376
Full Changelog: v0.1.14...v0.1.15
v0.1.14
Hotfix printing stacktraces from Scala CLI runner for Scala 3.x < 3.2.0
We fixed a nasty bug breaking any Scala CLI run using any Scala 3 version earlier than 3.2.0 on printing stacktraces.
Only Scala CLI 0.1.13 was affected.
$ scala-cli about
Scala CLI version: 0.1.13
Scala version (default): 3.2.0
$ scala-cli -S 3.1.3 -e 'throw Exception("Broken")'
Compiling project (Scala 3.1.3, JVM)
Compiled project (Scala 3.1.3, JVM)
Exception in thread "main" java.lang.NoSuchMethodError: 'long scala.runtime.LazyVals$.getOffsetStatic(java.lang.reflect.Field)'
at scala.cli.runner.StackTracePrinter.<clinit>(StackTracePrinter.scala:101)
at scala.cli.runner.StackTracePrinter$.coloredStackTraces(StackTracePrinter.scala:104)
at scala.cli.runner.StackTracePrinter$.$lessinit$greater$default$4(StackTracePrinter.scala:11)
at scala.cli.runner.Runner$.main(Runner.scala:18)
at scala.cli.runner.Runner.main(Runner.scala)
Added in #1358 by @romanowski
Build and internal changes
- Disable mill-scala-cli for now by @alexarchambault in #1335
- Update scala-cli.sh launcher for 0.1.13 by @github-actions in #1351
- Remove backslash which skip execution of
mv
command by @lwronski in #1353 - Fix import ordering by @alexarchambault in #1359
Updates
- Update scalafix stuff… by @alexarchambault in #1333
- Bump VirtusLab/scala-cli-setup from 0.1.12 to 0.1.13 by @dependabot in #1354
Full Changelog: v0.1.13...v0.1.14
v0.1.13
Change the default sub-command to repl
when no args are passed
We no longer default to the help
sub-command when no arguments are passed. Starting with 0.1.13
running Scala CLI with no args will launch the repl
.
$ scala-cli -S 3
Welcome to Scala 3.1.3 (17.0.3, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala>
When inputs are provided, Scala CLI defaults to the run
sub-command, as before.
$ cat hello.sc
println("Hello World")
$ scala-cli hello.sc
Hello World
This change was added by @Gedochao in #1268
Marking the project's workspace root with the project.settings.scala
file
Scala CLI now supports marking the workspace root directory with an optional configuration file: project.settings.scala
. The workspace root determines where the .bsp
and .scala-build
directories will be saved (which mostly affects what path should be opened in your IDE to import the Scala CLI project through BSP).
The settings file is also the recommended input for your project's using directives
. Otherwise, it functions similarly to other .scala
sources.
$ cat project.settings.scala
//> using scala "2.13.4"
$ cat hello.sc
println(util.Properties.versionString)
$ scala-cli hello.sc .
version 2.13.4
To see how exactly is the root directory resolved, see this document
Scala CLI is now built with Scala 3.2.0
We now rely on Scala 3.2.0
as the default internal Scala version used to build the project.
This change was added by @lwronski in #1314
Add resources support for Scala Native
Scala CLI now allows embedding resources (by default) in a Scala Native binary with the --native
flag.
$ cat resources/scala-native/foo.c
int foo(int i) {
return i + 42;
}
$ cat hello.scala
//> using platform "native"
//> using resourceDir "resources"
import scalanative.unsafe.*
@extern
def foo(int: CInt): CInt = extern
@main def main =
println(foo(3))
$ scala-cli hello.scala --native
45
Default to the run
sub-command instead of repl
when the -e
, --execute-script
, --execute-scala
or --execute-java
options are passed.
Even though we default to the repl
sub-command when no arguments are passed to Scala CLI, an exception to that rule is when a snippet is passed with one of the following options: -e
, --execute-script
, --execute-scala
or --execute-java
. In that case, the passed snippets are treated as inputs to be executed and switch the default to the run
sub-command.
$ scala-cli -e 'println("Hello")'
Hello
If you still want to pass a snippet to the repl
, you can either pass the repl
sub-command explicitly or use one of the following options, as before: --script-snippet
, --scala-snippet
or --java-snippet
.
$ scala-cli --script-snippet 'println("Hello")'
Welcome to Scala 3.1.3 (17.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> snippet_sc.main(Array.empty)
Hello
This change was introduced to make the -e
option backwards compatible with the scala
command.
Work in progress
Support for Markdown (experimental)
Scala CLI can now accept .md
inputs and run/compile a snippet of Scala code inside the markdown. Markdown sources are ignored by default unless passed explicitly as inputs. You can also enable including non-explicit .md
inputs by passing the --enable-markdown
option.
Plain scala
snippets are treated similarly to .sc
scripts which can be run by scala-cli
:
$ cat Example.md
This is a simple example of an `.md` file with a Scala snippet.
```scala
val message = "Hello from Markdown"
println(message)
```
scala-cli Example.md
Hello from Markdown
See this document for more details about the experimental Markdown support.
Add --python
option for the run
sub-command (experimental)
The run
sub-command can now run ScalaPy when the --python
option is passed.
$ cat helloscalapy.sc
import py.SeqConverters
val len = py.Dynamic.global.len(List(0, 2, 3).toPythonProxy)
println(s"Length is $len")
$ scala-cli helloscalapy.sc --python -S 2.13
Length is 3
Added in #1295 by @alexarchambault
Other changes
Documentation
- Correct using directives on configuration.md by @megri in #1278
- Improve dependencies doc by @Gedochao in #1287
Fixes
Build and internal changes
- Improve the error message for when a build's main class is ambiguous by @Gedochao in #1323
- Improve the error message for unsupported Scala version with Ammonite by @Gedochao in #1327
- Detect ARM64 macs when downloading coursier launcher by @keynmol in #1282
- Make test("...".only) work again in RunTestDefinitions by alexarchambault in #1294
- Use os-lib short-hand method trim when possible by alexarchambault in #1334
- Add missing repl tests by alexarchambault in #1332
- Scala CLI deb package - Priority and Section flag by @lwronski in #1338
Updates
- Update ammonite to 2.5.4-16-7317286d by @scala-steward in #1283
- Update mill-main to 0.10.7 by @scala-steward in #1284
- Update scalajs-env-nodejs_2.13 to 1.4.0 by @scala-steward in #1303
- Update jsoniter-scala-core_2.13 to 2.16.0 by @scala-steward in #1302
- Update core_2.13 to 3.7.6 by @scala-steward in #1299
- Update ammonite to 2.5.4-19-cd76521f by @scala-steward in #1298
- Update bsp4j to 2.1.0-M1 by @lwronski in #1277
- Bump VirtusLab/scala-cli-setup from 0.1.11 to 0.1.12 by @dependabot in #1306
- Update jsoniter-scala-core_2.13 to 2.17.0 by @scala-steward in #1311
- Update test-runner, tools to 0.4.7 by @scala-steward in #1317
- Update jsoniter-scala-core_2.13 to 2.17.1 by @scala-steward in #1320
- Update ammonite_3.1.3 to 2.5.4-22-4a9e6989 by @scala-steward in #1329
- Update jsoniter-scala-core_2.13 to 2.17.2 by @scala-steward in #1343
- Update python-native-libs to 0.2.4 by @scala-steward in #1341
- Update org.eclipse.jgit to 6.3.0.202209071007-r by @scala-steward in #1344
New Contributors
v0.1.12
Add --spark
, --spark-standalone
and --hadoop
options for the run
sub-command (experimental)
The run
sub-command can now run Spark jobs when the --spark
option is passed.
$ scala-cli run --spark SparkJob.scala
Similarly, it's possible to run Hadoop jobs by passing the --hadoop
option.
scala-cli run --hadoop HadoopJob.java
It's also possible to run Spark jobs without a Spark distribution by passing the --spark-standalone
option.
$ scala-cli run --spark-standalone SparkJob.scala
Added in #1129 by alexarchambault
Add the default Scala version to the output of the version
sub-command
The version
sub-command now includes both the Scala CLI version and the default Scala version.
$ scala-cli --version
Scala CLI version 0.1.12
Default Scala version: 3.1.3
$ scala-cli -version
Scala CLI version 0.1.12
Default Scala version: 3.1.3
$ scala-cli version
Scala CLI version 0.1.12
Default Scala version: 3.1.3
You can also pass the --cli-version
option to only get the Scala CLI version or the --scala-version
option
to only get the default Scala version.
$ scala-cli version --cli-version
0.1.12
$ scala-cli version --scala-version
3.1.3
This is potentially a breaking change if your automation relies on the output of the version
sub-command.
Enable passing the scalafmt
configuration with --scalafmt-conf
and --scalafmt-conf-str
It is now possible to pass a custom location of the scalafmt
configuration with the --scalafmt-conf
option for the
fmt
sub-command.
$ scala-cli fmt --scalafmt-conf path/to/the/conf/.scalafmt.conf
You can also pass the configuration straight from the terminal with --scalafmt-conf-str
.
$ scala-cli fmt --scalafmt-conf-str "version=3.5.5
runner.dialect=scala213"
Enable turning the --interactive
mode on permanently
It is now possible to set the --interactive
mode on by default, so that passing it explicitly isn't necessary.
The next time when you run a command with the --interactive
option set to on, Scala CLI will suggest to turn it on
permanently.
This is recommended for environments where scala-cli
is used by a human user only (and not by any automation).
$ scala-cli . --interactive
You have run the current scala-cli command with the --interactive mode turned on.
Would you like to leave it on permanently?
[0] Yes
[1] No
0
--interactive is now set permanently. All future scala-cli commands will run with the flag set to true.
If you want to turn this setting off at any point, just run `scala-cli config interactive false`.
Found several main classes. Which would you like to run?
[0] ScalaMainClass2
[1] ScalaMainClass1
[2] scripts.ScalaScript_sc
You can also configure it manually with the config
sub-command, by setting the interactive
property to true
.
$ scala-cli config interactive true
Other changes
Work in progress
SIP-46-related
- Restrict directives based on the command used by romanowski in #1259
Documentation
- NIT Improve some website docs by BlackAnubis7 in #1243
Build and internal changes
- Add 0.1.11 release notes to release_notes.md by BlackAnubis7 in #1228
- Temporary disable test gif by lwronski in #1261
- aarch64 fixes by alexarchambault in #1180
Updates
- Update mill launcher by alexarchambault in #1269
- Update scala-cli.sh launcher for 0.1.11 by github-actions in #1230
- Update jsoniter-scala-core_2.13 to 2.13.39 by scala-steward in #1239
- Update trees_2.13 to 4.5.12 by scala-steward in #1242
- Update jsoniter-scala-core_2.13 to 2.14.2 by scala-steward in #1241
- Update org name to VirtusLab for downloading scalafmt-native-image by lwronski in #1253
- Update core_2.13 to 3.7.4 by scala-steward in #1247
- Update case-app_2.13 to 2.1.0-M15 by scala-steward in #1245
- Update jsoniter-scala-core_2.13 to 2.15.0 by scala-steward in #1246
- Update cli-options_2.13, cli_2.13, ... to 0.1.8 by scala-steward in #1248
- Update metaconfig-typesafe-config to 0.11.1 by scala-steward in #1254
- Update ammonite to 2.5.4-14-dc4c47bc by scala-steward in #1255
- Update coursier-jvm_2.13, ... to 2.1.0-M6-53-gb4f448130 by scala-steward in #1256
- Update scala-packager-cli_2.13, ... to 0.1.27 by scala-steward in #1258
- Update bloop-config_2.13 to 1.5.3-sc-1 by scala-steward in #1257
- Update ammonite to 2.5.4-15-f4a8969b by scala-steward in #1264
- Update trees_2.13 to 4.5.13 by scala-steward in #1265
- Update slf4j-nop to 2.0.0 by scala-steward in #1273
- Update cli-options_2.13, cli_2.13, ... to 0.1.9 by scala-steward in #1272
- Bump VirtusLab/scala-cli-setup from 0.1.5 to 0.1.11 by dependabot in #1274
New Contributors
- BlackAnubis7 made their first contribution in #1228
Full Changelog: v0.1.11...v0.1.12