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 PreprocessedSources by @MaciejG604 in #2103
Updates and maintenance
- Downgrade GraalVM to
22.3.1
to fix M1 by @Gedochao in #2099 - Update slf4j-nop to 2.0.7 by @scala-steward in #2095
- Update sbt to 1.6.2 by @scala-steward in #2093
- Update bsp4j to 2.1.0-M4 by @scala-steward in #2086
- Bump
coursier
to2.1.3
by @Gedochao in #2077 - Update core_2.13 to 3.8.15 by @scala-steward in #2087
- Update file-tree-views to 2.1.10 by @scala-steward in #2088
- Bump
graalvm
to22.3.2
by @Gedochao in #2078 - Update asm to 9.5 by @scala-steward in #2092
- Bump coursier/setup-action from 1.3.2 to 1.3.3 by @dependabot in #2070
- Bump
jsoniter
,scalameta
,os-lib
andscala-collection-compat
by @Gedochao in #2064 - Bump
coursier
to2.1.2
by @Gedochao in #2063 - Bump
ammonite
to2.5.8
by @Gedochao in #2057 - Bump Scala.js to
1.13.1
by @Gedochao in #2062 - Bump coursier/setup-action from 1.3.1 to 1.3.2 by @dependabot in #2055
- Bump coursier/setup-action from 1.3.0 to 1.3.1 by @dependabot in #2042
- Dump bloop core to 1.5.6-sc-8 by @lwronski in #2013
- Fix snapshot versions calculation when the current version ends with
-RC.
by @Gedochao in #2002 - Update scala-cli.sh launcher for 1.0.0-RC1 by @github-actions in #1995
- Update scalafmt-cli_2.13, scalafmt-core to 3.7.3 by @scala-steward in #2094
Full Changelog: v1.0.0-RC1...v1.0.0-RC2