This repository gathers Scala 3 code examples coming from various websites - mostly from the Dotty project - or written by ourself. In particular it includes build scripts (Ant files, Bash scripts, batch files, Gradle scripts, Make scripts, Maven scripts) for experimenting with the Scala 3 language on a Windows machine. |
This document is part of a series of topics related to Scala 3 on Windows:
- Running Scala 3 on Windows ▼
- Building Scala 3 on Windows
- Data Sharing and Scala 3 on Windows
- OpenJDK and Scala 3 on Windows
Ada, Akka, C++, COBOL, Dafny, Dart, Deno, Docker, Erlang, Flix, Golang, GraalVM, Haskell, Kafka, Kotlin, LLVM, Modula-2, Node.js, Rust, Spark, Spring, TruffleSqueak, WiX Toolset and Zig are other topics we are continuously monitoring.
This project depends on the following external software for the Microsoft Windows platform:
- Git 2.47 (release notes)
- Scala 3.3 LTS 1 (release notes)
- Temurin OpenJDK 17 LTS 2 (release notes, bug fixes, Java 17 API)
Optionally one may also install the following software:
- Apache Ant 1.10 (requires Java 8) (release notes)
- Apache Maven 3.9 (requires Java 8+) (release notes)
- Bazel 7.4 LTS 3 (release notes)
- CFR 0.15 (Java decompiler)
- Gradle 8.10 (requires Java 8+) (release notes)
- JaCoCo 0.8 4 (change log)
- JavaFX 17 LTS (release notes)
- JavaFX 21 LTS (release notes)
- JITWatch 1.4 (requires Java 11+)
- Mill 0.12 (change log)
- MSYS2 2024 (change log)
- sbt 1.10 (requires Java 8+) (release notes)
- Scala 2.13 (requires Java 8+) (release notes, Scala API)
- Scala 2.13 DEV
- Scala 3.5 Next 5 (release notes)
- scala-cli 1.5 (release notes)
- Temurin OpenJDK 21 LTS 2 (release notes, Java 21 API)
- Visual Studio Code 1.95 (release notes)
☛ Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we definedC:\opt\
as the installation directory for optional software tools (in reference to the/opt/
directory on Unix).
For instance our development environment looks as follows (November 2024) 6:
C:\opt\apache-ant\ ( 40 MB) C:\opt\apache-maven\ ( 10 MB) C:\opt\bazel\ ( 47 MB) C:\opt\cfr-0.152\ ( 2 MB) C:\opt\Git\ (367 MB) C:\opt\gradle\ (138 MB) C:\opt\jacoco\ ( 10 MB) C:\opt\javafx-sdk-17.0.13\ (137 MB) C:\opt\javafx-sdk-21.0.5\ (138 MB) C:\opt\jdk-temurin-1.8.0u422-b05\ (189 MB) C:\opt\jdk-temurin-17.0.13_11\ (301 MB) C:\opt\jdk-temurin-21.0.5_11\ (326 MB) C:\opt\jitwatch-1.4.9\ ( 36 MB) C:\opt\mill\ ( 67 MB) C:\opt\msys64\ (5.5 GB) C:\opt\Python-3.11.1\ (299 MB) C:\opt\sbt\ (110 MB) C:\opt\scala-2.13.15\ ( 24 MB) C:\opt\scala-cli\ ( 95 MB) C:\opt\scala3-3.3.4\ ( 38 MB) C:\opt\scala3-3.5.2\ (131 MB) C:\opt\VSCode\ (341 MB)
🔎 Git for Windows provides a Bash emulation used to run
git.exe
from the command line (as well as over 250 Unix commands likeawk
,diff
,file
,grep
,more
,mv
,rmdir
,sed
andwc
).
Directory structure ▴
This project is organized as follows:
bin\*.bat bin\cfr-0.152.zip bin\3.0\{common.bat, scala.bat, scalac.bat, scaladoc.bat} bin\3.1\{common.bat, scala.bat, scalac.bat, scaladoc.bat} bin\3.2\{common.bat, scala.bat, scalac.bat, scaladoc.bat} bin\dotty\ docs\ dotty\ (Git submodule) examples\{README.md, dotty-example-project, ..} maven-plugins\{README.md, scala-maven-plugin, etc.} myexamples\{README.md, 00_AutoParamTupling, ..} plugin-examples\{README.md, DivideZero, ..} rockthejvm-examples\{README.md, Enums, ..} semanticdb-examples\{README.md, hello, ..} CONTRIBUTIONS.md DEPS.md README.md RESOURCES.md setenv.bat UBUNTU_WSL.md
where
- directory
bin\
provides several utility batch files. - file
bin\cfr-0.152.zip
contains a zipped distribution of CFR. - directory
bin\3.2\
contains the batch commands for Scala 3. - directory
bin\dotty\
contains several batch files/bash scripts for building the Scala 3 software distribution on a Windows machine. - directory
docs\
contains Scala 3 related papers/articles (see filedocs\README.md
). - directory
dotty\
contains our fork of the lampepfl/dotty repository as a Github submodule. - directory
examples\
contains Scala 3 examples grabbed from various websites (see fileexamples\README.md
). - directory
maven-plugins\
presents our Maven pluginscala-maven-plugin
. - directory
myexamples\
contains self-written Scala 3 examples (see filemyexamples\README.md
). - directory
plugin-examples\
contains Scala 3 plugin examples (see fileplugin-examples\README.md
). - directory
rockthejvm-examples\
contains Scala 3 code examples (see filerockthejvm-examples\README.md
). - directory
semanticdb-examples\
contains SemanticDB code examples (see filesemanticdb-examples\README.md
). - file
CONTRIBUTIONS.md
lists PRs and issues we reported so far. - file
DEPS.md
lists library dependencies of available Scala distributions. - file
README.md
is the Markdown document for this page. - file
RESOURCES.md
is the Markdown document presenting external resources. - file
setenv.bat
is the batch command for setting up our environment. - file
UBUNTU_WSL.md
presents a Scala 3 code examples in Ubuntu WSL.
We also define a virtual drive – e.g. drive Y:
– in our working environment in order to reduce/hide the real path of our project directory (see article "Windows command prompt limitation" from Microsoft Support).
🔎 Inside batch file
setenv.bat
we use the Windows external commandsubst
to create virtual drives; for instance:> subst Y: %USERPROFILE%\workspace\dotty-examples
In the next section we give a brief description of the batch files present in this project.
Batch/Bash commands ▴
We distinguish different sets of batch/bash commands:
-
setenv.bat
– This batch command makes external tools such asmaven.cmd
,mill.bat
andsbt.bat
directly available from the command prompt (see section Project dependencies).> setenv help Usage: setenv { <option> | <subcommand> } Options: -bash start Git bash shell instead of Windows command prompt -debug print commands executed by this script -verbose print progress messages Subcommands: help print this help message
-
Directory
bin\
– This directory contains several utility batch files:cleanup.bat
removes the generated class files from every example directory (both inexamples\
andmyexamples\
directories).dirsize.bat <dir_path_1> ..
prints the size in Kb/Mb/Gb of the specified directory paths.getnightly.bat
downloads/installs the distribution from the latest Dotty nightly build.searchjars.bat <class_name>
searches for the given class name into all Scala JAR files.timeit.bat <cmd_1> { & <cmd_2> }
prints the execution time of the specified commands.touch.bat <file_path>
updates the modification date of an existing file or creates a new one.
-
Directory
bin\3.0\
- This directory contains batch files to be copied to thebin\
directory of the Scala 3 installation for versions prior to 3.0.2 in order to use thescalac.bat
,scaladoc.bat
andscala.bat
commands on Microsoft Windows.☛ Starting with version 3.0.2 those batch files are included in the Scala 3 software distribution (see PR#13006, itself based on PR#5444).
> dir /b c:\opt\scala3-3.3.4\bin common common.bat scala scala.bat scalac scalac.bat scaladoc scaladoc.bat
-
File
bin\dotty\build.bat
- This batch command generates the Scala 3 software distribution from the Windows command prompt. -
File
bin\dotty\build.sh
- This bash command generates the Scala 3 software distribution from the Git Bash command prompt. -
File
examples\*\build.bat
- Finally each example can be built/run using thebuild.bat
command.☛ We favor
build.bat
for the following reasons:- It matches user commands executed from the Windows command prompt.
- It provides subcommands for working with CFR, Scalafmt, JUnit and more.
- Code examples are simple (mostly one single source file).
- We don't need the
sbt
machinery (eg. library dependencies, sbt server).
> build Usage: build { <option> | <subcommand> } Options: -debug print commands executed by this script -explain set compiler option -explain -explain-types set compiler option -explain-types -main:<name> define main class name (default: Main) -print print IR after compilation phase 'lambdaLift' -scala2 use Scala 2 tools -scala3 use Scala 3 tools (default) -tasty compile both from source and TASTy files -timer print the execution time -verbose print progress messages Subcommands: clean delete generated files compile compile Java/Scala source files decompile decompile generated code with CFR doc generate HTML documentation help print this help message lint analyze Scala source files with Scalafmt run[:i] execute main class (instrumented execution: :i) test execute unit tests with JUnit Properties: (to be defined in SBT configuration file project\build.properties) main.class alternative to option -main:<name> main.args list of arguments to be passed to main class
Optional tools ▴
-
Build tools
Code examples in directories
examples\
andmyexamples\
can also be built with the following tools as an alternative to thebuild.bat
command (seeexamples\README.md
andmyexamples\README.md
for more details):Build tool Build file Parent file Usage example ant.bat
build.xml
build.xml
ant
clean compile run
bazel.exe
BUILD
n.a. bazel
run :enum-Planet
cmd.exe
build.bat
build clean run
gradle.bat
build.gradle
common.gradle
gradle
clean build run
make.exe
Makefile
Makefile.inc
make
clean run
mill.bat
build.sc
common.sc
mill -i app
mvn.cmd
pom.xml
pom.xml
mvn
clean compile test
sbt.bat
build.sbt
n.a. sbt
clean compile run
-
Decompiler tools
As an alternative to the standard
javap.exe
class decompiler one may usecfr.bat
(simply extractbin\cfr-0.152.zip
toc:\opt\
) which prints Java source code instead of Java bytecode:> cfr myexamples\00_AutoParamTupling\target\classes\myexamples\Main.class /* * Decompiled with CFR 0.152. */ package myexamples; import myexamples.Main$; public final class Main { public static void test01() { Main$.MODULE$.test01(); } public static void main(String[] arrstring) { Main$.MODULE$.main(arrstring); } public static void test02() { Main$.MODULE$.test02(); } }
Here is the console output from command
javap.exe
with option-c
for the same class file:> javap -c myexamples\00_AutoParamTupling\target\classes\myexamples\Main.class Compiled from "Main.scala" public final class myexamples.Main { public static void main(java.lang.String[]); Code: 0: getstatic #13 // Field myexamples/Main$.MODULE$:Lmyexamples/Main$; 3: aload_0 4: invokevirtual #15 // Method myexamples/Main$.main:([Ljava/lang/String;)V 7: return public static void test02(); Code: 0: getstatic #13 // Field myexamples/Main$.MODULE$:Lmyexamples/Main$; 3: invokevirtual #19 // Method myexamples/Main$.test02:()V 6: return public static void test01(); Code: 0: getstatic #13 // Field myexamples/Main$.MODULE$:Lmyexamples/Main$; 3: invokevirtual #22 // Method myexamples/Main$.test01:()V 6: return }
Usage examples ▴
We execute command setenv.bat
once to setup our development environment; it makes external tools such as bazel.exe
, mvn.cmd
, sbt.bat
and git.exe
directly available from the command prompt.
> setenv Tool versions: javac 17.0.13, scalac 2.13.15, scalac 3.3.4, scalafmt 3.7.17, ant 1.10.15, gradle 8.10.2, mvn 3.9.9, sbt 1.10.3, scala-cli 1.5.1, mill 0.12.1, bazel 7.4.0, cfr 0.152, make 3.81, python 3.11.1, jacoco 0.8.12, git 2.47.0, diff 3.10, bash 5.2.37(1) > where sbt scala-cli C:\opt\sbt\bin\sbt C:\opt\sbt\bin\sbt.bat C:\opt\scala-cli\scala-cli.exe
Other development tools such as javac.exe
and scalac.bat
are accessible through the corresponding environment variable, e.g. JAVA_HOME
for javac.exe
, SCALA_HOME
resp. SCALA3_HOME
for scalac.bat
and PYTHON_HOME
for python.exe
.
> where javac INFO: Could not find files for the given pattern(s). > where /r %JAVA_HOME% javac C:\opt\jdk-temurin-17.0.13_11\bin\javac.exe > %JAVA_HOME%\bin\javac -version javac 17.0.13
Command setenv.bat -verbose
also prints the tool paths and defined environment variables:
> setenv -verbose Tool versions: javac 17.0.13, scalac 2.13.15, scalac 3.3.4, scalafmt 3.7.12, ant 1.10.15, gradle 10, mvn 3.9.9, sbt 1.10.3, scala-cli 1.5.1, mill 0.12.1, bazel 7.4.0, cfr 0.152, make 3.81, python 3.11.1, jacoco 0.8.12, git 2.47.0, diff 3.10, bash 5.2.37(1) Tool paths: C:\opt\jdk-temurin-11.0.21_9\bin\javac.exe C:\opt\scala-2.13.15\bin\scalac.bat C:\opt\scala3-3.3.4\bin\scalac.bat %LOCALAPPDATA%\Coursier\data\bin\scalafmt.bat C:\opt\apache-ant\bin\ant.bat C:\opt\gradle\bin\gradle.bat C:\opt\mill\mill.bat C:\opt\apache-maven\bin\mvn.cmd C:\opt\sbt\bin\sbt.bat C:\opt\scala-cli\scala-cli.exe C:\opt\mill\mill.bat C:\opt\bazel\bazel.exe C:\opt\cfr-0.152\bin\cfr.bat C:\opt\make-3.81\bin\make.exe C:\opt\Python-3.11.1\python.exe C:\opt\jacoco\lib\jacococli.jar C:\opt\Git\bin\git.exe C:\opt\Git\usr\bin\diff.exe C:\opt\Git\bin\bash.exe Environment variables: "ANT_HOME=C:\opt\apache-ant" "BAZEL_HOME=c:\opt\bazel" "CFR_HOME=C:\opt\cfr-0.152" "COURSIER_DATA_DIR=%LOCALAPPDATA%\coursier\data" "COURSIER_HOME=C:\opt\coursier-2.1.7" "GIT_HOME=C:\opt\Git" "GRADLE_HOME=C:\opt\gradle" "JAVA_HOME=C:\opt\jdk-temurin-17.0.13_11" "JAVA17_HOME=C:\opt\jdk-temurin-17.0.13_11" "JAVA21_HOME=C:\opt\jdk-temurin-21.0.5_11" "JAVAFX_HOME=C:\opt\javafx-sdk-21.0.5" "MSVS_HOME=X:" "MSYS_HOME=C:\opt\msys64" "PYTHON_HOME=C:\opt\Python-3.11.1" "SBT_HOME=C:\opt\sbt" "SCALA_CLI_HOME=C:\opt\scala-cli" "SCALA_HOME=C:\opt\scala-2.13.15" "SCALA3_HOME=C:\opt\scala3-3.3.4" "SCALA3_NEXT_HOME=C:\opt\scala3-3.5.2" Path associations: I:\: => %USERPROFILE%\workspace-perso\dotty-examples
Command cleanup.bat
removes the output directories (ie. target\
) from the example projects:
> cleanup Finished to clean up 2 subdirectories in Y:\dotty\cdsexamples Finished to clean up 16 subdirectories in Y:\dotty\examples Finished to clean up 12 subdirectories in Y:\dotty\myexamples
Command dirsize.bat
returns the size (in Kb, Mb or Gb) of the specified directory paths:
> dirsize examples myexamples c:\opt\scala3-3.3.4 c:\opt\jdk-temurin-17.0.13_11 Size of directory "examples" is 3.9 Mb Size of directory "myexamples" is 1.2 Mb Size of directory "c:\opt\scala3-3.3.4" is 35.7 Mb Size of directory "c:\opt\jdk-temurin-17.0.13_11" is 304.0 Mb
By default command getnightly.bat
downloads the library files of the latest Dotty nightly build available from the Maven Central Repository and saves them into directory out\nightly\
.
> getnightly Usage: getnightly { <option> | <subcommand> } Options: -debug print commands executed by this script -timer print total execution time -verbose print download progress Subcommands: activate activate the nightly build library files download download nighty build files and quit (default) help print this help message restore restore the default Scala library files
Command getnightly.bat download
with options -verbose
also displays the download progress:
> getnightly -verbose download Delete directory "out\nightly" Download Scala 3 nightly files from Maven repository Downloading file scala3-language-server_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 148.9 Kb Downloading file scala3-compiler_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 20.3 Mb Downloading file scala3-sbt-bridge-3.5.0-RC1-bin-20240514-7c9aae3-NIGHTLY.jar ... 31.2 Kb Downloading file scala3-tasty-inspector_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 17.4 Kb Downloading file scala3-library_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 1.2 Mb Downloading file scala2-library-tasty-experimental_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 3 Mb Downloading file scala3-staging_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 40.7 Kb Downloading file scala3-presentation-compiler_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 1.7 Mb Downloading file scala3-library_sjs1_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 1.9 Mb Downloading file scala3-interfaces-3.5.0-RC1-bin-20240514-7c9aae3-NIGHTLY.jar ... 3.9 Kb Downloading file scala2-library-cc-tasty-experimental_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 3 Mb Downloading file scaladoc_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 4.7 Mb Downloading file tasty-core_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar ... 94.5 Kb Downloading file antlr4-runtime-4.7.2.jar ... 330 Kb [...] Downloading file common ... 6 Kb Downloading file common.bat ... 2.9 Kb Converting file common.bat to DOS format Downloading file scala ... 1.8 Kb Downloading file scala.bat ... 2.6 Kb Converting file scala.bat to DOS format Downloading file scalac ... 2.5 Kb Downloading file scalac.bat ... 3.7 Kb Converting file scalac.bat to DOS format Downloading file scaladoc ... 5 Kb Downloading file scaladoc.bat ... 4.6 Kb Converting file scaladoc.bat to DOS format Finished to download 54 files to directory "%LOCALAPPDATA%\Temp\scala3-nightly" Retrieve revision for hash "3e105f2" from GitHub repository "lampepfl/dotty" File "%LOCALAPPDATA%\Temp\scala3-nightly\VERSION": version:=3.6.2-RC1-bin-20240514-7c9aae3-NIGHTLY revision:=7c9aae3 buildTime:=2024-05-15 23:09:19+02:00
Output directory %TEMP%\scala3-nightly\
contains the two subdirectories bin\
and lib\
:
> dir /b %TEMP%\scala3-nightly\bin %TEMP%\scala3-nightly\lib common common.bat scala scala.bat scalac scalac.bat scaladoc scaladoc.bat antlr-runtime-4.7.2.jar autolink-0.6.0.jar [...] scala-asm-9.6.0-scala-1.jar scala-library-2.13.12.jar scala2-library-cc-tasty-experimental_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar scala2-library-tasty-experimental_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar scala3-compiler_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar scala3-interfaces-3.5.0-RC1-bin-20240514-7c9aae3-NIGHTLY.jar scala3-language-server_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar scala3-library_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar scala3-library_sjs1_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar scala3-presentation-compiler_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar scala3-sbt-bridge-3.6.2-RC1-bin-20240514-7c9aae3-NIGHTLY.jar scala3-staging_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar scala3-tasty-inspector_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar scaladoc_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar snakeyaml-2.0.jar strftime4j-1.0.6.jar tasty-core_3.6.2-RC1-bin-20241025-91ef921-NIGHTLY.jar
Concretely, subcommand activate
switches to the nightly build version and subcommand restore
restore the path to the Scala 3 installation directory.
> getnightly activate Active Scala 3 installation is 3.6.2-RC1-bin-20241025-91ef921-NIGHTLY (was 3.3.4) > %SCALA3_HOME%\bin\scalac -version Scala compiler version 3.6.2-RC1 -- Copyright 2002-2024, LAMP/EPFL > getnightly restore Active Scala 3 installation is 3.3.4 > %SCALA3_HOME%\bin\scalac -version Scala compiler version 3.3.4 -- Copyright 2002-2024, LAMP/EPFL
⚠️ You need write access to the Scala 3 installation directory (e.g.C:\opt\scala3-3.3.4\
in our case) in order to successfully run theactivate/reset
subcommands.
Command searchjars.bat
helps us to search for class file names in the following directories: project's lib\
directory (if present), Scala's lib\
directory, Java's lib\
directory and Ivy/Maven default local directories.
> searchjars -help Usage: searchjars { <option> | <class_name> } Options: -artifact search in ~\.ivy2 and ~\.m2 directories -help print this help message -ivy search in ~\.ivy directory -java search in Java library directories -maven search in ~\.m2 directory -scala search in Scala library directories -verbose print progress messages Arguments: <class_name> class name
For instance we get the following output when passing class name System
to command searchjars.bat
(class file names are printed with full path and are prefixed with their containing JAR file):
> searchjars System Searching for class name System in archive files C:\opt\scala3-3.3.4\lib\*.jar jline-reader-3.19.0.jar:org/jline/reader/impl/completer/SystemCompleter.class scala-library-2.13.15.jar:scala/sys/SystemProperties$.class scala-library-2.13.15.jar:scala/sys/SystemProperties.class Searching for class name System in archive files C:\opt\scala-2.13.15\lib\*.jar jline-3.19.0.jar:org/jline/builtins/SystemRegistryImpl$CommandOutputStream.class [...] scala-library.jar:scala/sys/SystemProperties$.class scala-library.jar:scala/sys/SystemProperties.class Searching for class name System in archive files C:\opt\jdk-temurin-17.0.13_11\lib\*.jar jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystem$1.class [...] jrt-fs.jar:jdk/internal/jrtfs/SystemImage$2.class jrt-fs.jar:jdk/internal/jrtfs/SystemImage.class Searching for class name System in archive files c:\opt\javafx-sdk-17.0.13_11\lib\*.jar javafx.graphics.jar:com/sun/glass/ui/SystemClipboard.class [...] javafx.graphics.jar:com/sun/javafx/tk/TKSystemMenu.class javafx.web.jar:com/sun/webkit/FileSystem.class
Searching for an unknown class name - e.g. BinarySearch
- produces the following output:
> searchjars BinarySearch Searching for class name BinarySearch in archive files C:\opt\scala3-3.3.4\lib\*.jar Searching for class name BinarySearch in archive files C:\opt\scala-2.13.15\lib\*.jar Searching for class name BinarySearch in archive files C:\opt\jdk-temurin-17.0.13_11\lib\*.jar
Searching for FileSystem
with option -artifact
produces the following output:
> searchjars FileSystem -artifact Searching for class name FileSystem in archive files C:\opt\scala3-3.3.4\lib\*.jar Searching for class name FileSystem in archive files C:\opt\scala-2.13.15\lib\*.jar Searching for class name FileSystem in archive files c:\opt\jdk-temurin-17.0.13_11\lib\*.jar jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystem$1.class jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystem.class jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystemProvider$1.class jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystemProvider$JrtFsLoader.class jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystemProvider.class Searching for class name FileSystem in archive files c:\opt\javafx-sdk-17\lib\*.jar javafx.web.jar:com/sun/webkit/FileSystem.class Searching for class name FileSystem in archive files %USERPROFILE%\.ivy2\cache\*.jar okhttp-3.14.2.jar:okhttp3/internal/io/FileSystem$1.class okhttp-3.14.2.jar:okhttp3/internal/io/FileSystem.class ivy-2.3.0-sbt-839fad1cdc07cf6fc81364d74c323867230432ad.jar:org/apache/ivy/plugins/resolver/FileSystemResolver.class ivy-2.3.0-sbt-88d6a93d15f9b029958c1c289a8859e8dfe31a19.jar:org/apache/ivy/plugins/resolver/FileSystemResolver.class ivy-2.3.0-sbt-fa726854dd30be842ff9e6d2093df6adfe3871f5.jar:org/apache/ivy/plugins/resolver/FileSystemResolver.class Searching for class name FileSystem in archive files %USERPROFILE%\.m2\repository\*.jar commons-io-2.2.jar:org/apache/commons/io/FileSystemUtils.class commons-io-2.5.jar:org/apache/commons/io/FileSystemUtils.class commons-io-2.6.jar:org/apache/commons/io/FileSystemUtils.class ivy-2.4.0.jar:org/apache/ivy/plugins/resolver/FileSystemResolver.class sigar-1.6.4.jar:org/hyperic/sigar/FileSystem.class [...] stagemonitor-os-0.88.9.jar:org/stagemonitor/os/metrics/FileSystemMetricSet.class
Batch file timeit.bat
prints the execution time (hh:MM:ss
format) of the specified command (possibly given with options and parameters):
> timeit dir /b .gitignore .gradle build.bat build.gradle build.sbt build.sc build.xml pom.xml project settings.gradle src target Execution time: 00:00:01 > timeit build clean compile Execution time: 00:00:08
Chaining of commands is also possible. Note that the command separator (either &&
or &
) must be escaped if the command chain is not quoted. For instance:
s > timeit build clean compile ^&^& ant run ... Execution time: 00:00:11 > timeit "build clean compile && ant run" ... Execution time: 00:00:11
🔎 The
&&
command separator performs error checking - that is, the commands to the right of the&&
command run if and only if the command to the left of&&
succeeds. The&
command does not perform error checking - that is, all commands run.
Batch file build.bat
is a basic build script consisting of ~800 lines of batch/Powershell code 7.
Running command build
.bat with no option in project examples\enum-Planet
generates the following output:
> build clean compile run Your weight on MERCURY (0) is 0.37775761520093526 Your weight on SATURN (5) is 1.0660155388115666 Your weight on VENUS (1) is 0.9049990998410455 Your weight on URANUS (6) is 0.9051271993894251 Your weight on EARTH (2) is 0.9999999999999999 Your weight on NEPTUNE (7) is 1.1383280724696578 Your weight on MARS (3) is 0.37873718403712886 Your weight on JUPITER (4) is 2.5305575254957406
More usage examples are presented in examples\README.md
resp. myexamples\README.md
Scala REPL is an interactive tool for evaluating Scala expressions. Internally, it executes a source script by wrapping it in a template and then compiling and executing the resulting program.
⚠️ Batch filescala.bat
is based on the bash scriptscala
available from the standard Scala 3 distribution. We also have submitted pull request #5444 to add that batch file to the Scala 3 distribution.
> where scala C:\opt\scala3-3.3.4\bin\scala C:\opt\scala3-3.3.4\bin\scala.bat > scala -version Scala code runner version 3.3.4 -- Copyright 2002-2024, LAMP/EPFL > scala Starting scala REPL... scala> :help The REPL has several commands available: :help print this summary :load <path> interpret lines in a file :quit exit the interpreter :type <expression> evaluate the type of the given expression :imports show import history :reset reset the repl to its initial state, forgetting all session entries scala> System.getenv().get("JAVA_HOME") val res0: String = C:\opt\jdk-temurin-17.0.13_11 scala> System.getenv().get("SCALA3_HOME") val res1: String = C:\opt\scala3-3.3.4 scala> :load myexamples/HelloWorld/src/main/scala/HelloWorld.scala // defined object HelloWorld scala> HelloWorld.main(Array()) Hello world! scala>:quit
Footnotes ▴
[1] Scala 3 LTS versions ↩
-
The distinction between LTS and Next versions of Scala 3 is presented on the page "Long-term compatibility plans for Scala 3" posted on August 17, 2022.
In particular it makes the following statement : "We suggest end users stick to the LTS version. It will give you the best tooling support and a stable compiler. If you are migrating a bigger project from Scala 2, you should migrate it straight to the newest LTS."
[2] Java LTS versions ↩
- Oracle annonces in his Java SE Support Roadmap he will stop public updates of Java SE 8 for commercial use after January 2019. Current LTS versions are (from Oracle's support roadmap):
-
Java LTS Version GA End of life 25 September 2025 September 2033 21 September 2023 September 2031 17 September 2021 September 2029 11 September 2018 September 2026 8 March 2014 December 2030 (1) (1) The Extended Support uplift fee will be waived for the period March 2022 - December 2030 for Java SE 8. - NB. See also Zulu's support roadmap.
[3] Using Bazel on Windows ↩
-
See also the Support matrix on the Bazel website.
Bazel LTS Version GA End of support 8.0.0 Late 2024 - 7.4.0 October 2024 December 2026 7.3.1 December 2023 December 2026 6.5.0 December 2022 December 2025 5.4.1 January 2022 January 2025 - Read the page Builds on Windows of the Bazel website for tips to build with MSVC, Clang, Java or Python on a Windows machine.
-
For instance, for Visual Studio 2019, we set variable
BAZEL_VC
to the Visual C++ Build Tools installation directory: -
> set "BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC"
[4] JaCoCo and Java support ↩
-
JaCoCo version Supported Java version Depends on ASM 0.8.12 (March 2024) 21 and 22 9.7 0.8.11 (Oct 2023) 21 and 22 9.6 0.8.10.2 (April 2023) 19 and 20 9.5 0.8.9 (March 2023) 19 and 20 9.5 0.8.8 (April 2022) 17 and 18 9.2 0.8.7 (May 2021) 15 and 16 9.1 0.8.6 (Sept 2020) 14 8.2 0.8.5 (Oct 2019) 13 7.2 0.8.4 (May 2019) 12 7.1 0.8.3 (Jan 2019) 11 7.0 0.8.2 (Aug 2018) 6.3.2 0.8.1 (March 2018) 10 0.8.0 (Jan 2018) 9 6.0
[5] Scala 3 Next ↩
-
The attentive Scala 3 user will have noticed that the size of the Scala 3 software distribution has increased significantly with version 3.5.0.
That size increase of the Scala 3 software distribution comes from a big reorganization of its contents :Scala 3 Version Archive size Installation size 3.3.4 LTS 34 MB 38.6 MB 3.5.0 Next 70 MB 131 MB scala-cli
(91 MB) from VIRTUSLAB is now part of the distribution- directory
lib\
now contains only 3 JAR files: . - directory
maven2\
(40 MB) is new; this application specific Maven repository contains the Maven packages Scala 3 depends on.
Class-Path
. We present its usage in the manifest filelib\scala.jar\META-INF\MANIFEST.MF
:Manifest-Version: 1.0 Class-Path: ../maven2/org/scala-lang/scala3-interfaces/3.5.0/scala3-in terfaces-3.5.0.jar ../maven2/org/scala-lang/scala3-compiler_3/3.5.0/s cala3-compiler_3-3.5.0.jar ../maven2/org/scala-lang/scala3-library_3/ 3.5.0/scala3-library_3-3.5.0.jar ../maven2/org/scala-lang/tasty-core_ 3/3.5.0/tasty-core_3-3.5.0.jar ../maven2/org/scala-lang/modules/scala -asm/9.6.0-scala-1/scala-asm-9.6.0-scala-1.jar ../maven2/org/scala-sb t/compiler-interface/1.9.6/compiler-interface-1.9.6.jar ../maven2/org /jline/jline-reader/3.25.1/jline-reader-3.25.1.jar ../maven2/org/jlin e/jline-terminal/3.25.1/jline-terminal-3.25.1.jar ../maven2/org/jline /jline-terminal-jna/3.25.1/jline-terminal-jna-3.25.1.jar ../maven2/or g/scala-lang/scala-library/2.13.15/scala-library-2.13.15.jar ../maven 2/org/scala-sbt/util-interface/1.9.8/util-interface-1.9.8.jar ../mave n2/org/jline/jline-native/3.25.1/jline-native-3.25.1.jar ../maven2/ne t/java/dev/jna/jna/5.14.0/jna-5.14.0.jar
[6] Downloads ↩
- In our case we downloaded the following installation files (see section 1):
-
0.12.1-assembly (mill) ( 64 MB) apache-ant-1.10.15-bin.zip ( 9 MB) apache-maven-3.9.9-bin.zip ( 10 MB) bazel-7.4.0-windows-x86_64.zip ( 40 MB) gradle-8.10.2-bin.zip (124 MB) jacoco-0.8.12.zip ( 4 MB) jitwatch-ui-1.4.9-shaded-win.jar ( 36 MB) msys2-x86_64-20240727.exe ( 94 MB) OpenJDK8U-jdk_x64_windows_hotspot_8u432b06.zip ( 99 MB) OpenJDK17U-jdk_x64_windows_hotspot_17.0.13_11.zip (188 MB) OpenJDK21U-jdk_x64_windows_hotspot_21.0.5_11.zip (191 MB) openjfx-17.0.13_windows-x64_bin-sdk.zip ( 39 MB) openjfx-17.0.13_windows-x64_bin-jmods.zip ( 37 MB) openjfx-21.0.5_windows-x64_bin-sdk.zip ( 39 MB) openjfx-21.0.5_windows-x64_bin-jmods.zip ( 37 MB) PortableGit-2.47.0-64-bit.7z.exe ( 60 MB) sbt-1.10.3.zip ( 17 MB) scala-2.13.15.zip ( 22 MB) scala-cli-x86_64-pc-win32.zip ( 31 MB) scala3-3.3.4.zip ( 34 MB) scala3-3.5.2.zip (123 MB)
[7] PowerShell ↩
- Command Prompt has been around for as long as we can remember, but starting with Windows 10 build 14971, Microsoft is trying to make PowerShell the main command shell in the operating system.