Scala¶
Current Default Scala Version: 3.7.1
Overview¶
This package provides a minimal interface to the scala and java compiler to define, compile and run library/application builds. Users can also run .sc scala script files through scala's standard scala-cli integration.
Warning: The interfaces provided by this module are designed to be quite low-level, a real build system workflow should be implemented by a build flow package that will structure and run this module's tools to accomodate complex scenarios.
To build projects it is recommended to use the Applib Build Flow for a user friendly experience.
Running REPL or CLI Code runner¶
To get started with scala quicly, you can just run a script or use the scala REPL, using the default versions used in KISSB:
- Run the REPL: ./kissbw .scala.runner
- Run a script: ./kissbw .scala.runner myscript.sc ./kissbw myscript.sc
Scala scripts can define embedded dependencies which are resolved automatically, scala even provides a default toolkit dependency to easily provide API to manipule files, make http requests or even serve simple http apps.
For more details look at the Scala Toolkit documentation.
Overriding Scala and JVM version¶
Scala and Java are defined using two default variables:
- jvm.default.version, overridable using JVM_DEFAULT_VERSION on the command line
- scala.default.version, overridable using SCALA_DEFAULT_VERSION on the command line
Using a build script¶
KISSB provides a package to configure a scala build, and can generate a BLOOP configuration for compatibility with both IntelliJ and Scala Metals IDE
To setup a new source module:
This call will setup a default source module named main, with src/main/scala and src/test/scala source folders, and the default scala version set in the package.
To compile your module:
To add dependencies:
with ARTIFACT being a list of GROUPID:ARTIFACTID:VERSION format
Scalatest¶
To use scala test, configure it on top of an existing source module:
This will create a main/test module with src/test/scala source folder
Bloop support¶
A bloop package is available which will generate a bloop json configuration, which can be loaded by bloop supporting IDE plugins like Scala Metals
Scala Commands Reference¶
scala.addDependencies¶
Add dependencies to specified module If a dependency is named @xxxx it will refer to another project module
scala.addDependencies
module ?args?
Parameters¶
module |
Not documented. |
scala.amm¶
Run provided script File using ammonite
scala.amm
scriptFile
Parameters¶
scriptFile |
Not documented. |
scala.compile¶
Compile module
scala.compile
module ?args?
Parameters¶
module |
Not documented. |
scala.defaultRunEnv¶
Runs coursier to get default scala and jvm versions set in this plugin
scala.defaultRunEnv
?args?
Parameters¶
Return value¶
Returns an environment dict that can be used by the exec module to run scala command line or scalac
scala.getModuleEnv¶
Runs couriser to get scala and jvm path environment for the provided module
scala.getModuleEnv
module
Parameters¶
module |
Not documented. |
Return value¶
Returns an environment dict that can be used by the exec module to run scala command line or scalac
scala.init¶
Init project module, this method creates ${module}.xxx variables used by other functions and tools to build the module and output files in the desired location Users can provide arguments to customize behavior.
scala.init
module ?args?
Parameters¶
module |
Not documented. |
args |
Supported arguments described below: |
-baseDir |
Base directory of module, default to current directory |
-javac-args |
Arguments for javac |
-jvm-name |
JVM name used to run scala, ${::jvm.default.version} - The name is used by coursier to use a specific vendor of the JVM. |
-jvm-version |
JVM version used to run scala, default to ${::jvm.default.version} |
-scala |
Scala version , default to ${::scala.default.version} module variable |
-scalac-args |
Arguments for scalac |
-srcDirs |
Source directories to use for compilation |
-target |
JVM version target output for scalac, default to ${::jvm.default.version} |
scala.jvm¶
Select the JVM version for the application module
scala.jvm
module version ?descriptor?
Parameters¶
module |
Not documented. |
version |
Not documented. |
descriptor |
Not documented. Optional, default "" . |
scala.repl¶
scala.repl
?args?
Parameters¶
scala.resolveDeps¶
Returns list of dependencies, including module dependencies output build directory in classpath If -classpath if passed, module's own classes output is added to the results to generate a full classpath
scala.resolveDeps
module ?args?
Parameters¶
module |
Not documented. |
-classpath |
Pass to add module's output class directory to list of dependencies |
Return value¶
Returns list of dependencies, including module dependencies output build directory in classpath If -classpath if passed, module's own classes output is added to the results to generate a full classpath
scala.run¶
Run module's provided main class - doesn't build
scala.run
module mainClass ?args?
Parameters¶
module |
Not documented. |
mainClass |
Not documented. |
scala.runner¶
scala.runner
?args?
Parameters¶
scala.script¶
scala.script
file
Parameters¶
file |
Not documented. |
Bloop Commands Reference¶
bloop.compile¶
Compile via bloop
bloop.compile
module
Parameters¶
module |
Not documented. |
bloop.config¶
Configure module for bloop usage
bloop.config
module
Parameters¶
module |
Not documented. |
bloop.getBloopEnv¶
bloop.getBloopEnv
module
Parameters¶
module |
Not documented. |
bloop.projects¶
Run bloop projects command
bloop.projects
?module?
Parameters¶
module |
Not documented. Optional, default main . |
bloop.run¶
Run module's main class via bloop
bloop.run
module main ?args?
Parameters¶
module |
Not documented. |
main |
Not documented. |