title | sidebar_position |
---|---|
Directives |
2 |
This document describes as scala-cli behaves if run as scala
command. See more information in SIP-46
This document is a specification of the scala
runner.
For now it uses documentation specific to Scala CLI but at some point it may be refactored to provide more abstract documentation.
Documentation is split into sections in the spirit of RFC keywords (MUST
, SHOULD
).
Add Scala compiler options
//> using option
option
//> using options
option1, option2 …
//> using option "-Xasync"
//> using options "-Xasync", "-Xfatal-warnings"
Adds compiler plugins
using plugin
org:
name:
ver
//> using plugin "org.typelevel:::kind-projector:0.13.2"
Add dependencies
//> using lib "
org:
name:
ver"
//> using lib "org.scalatest::scalatest:3.2.10"
//> using lib "org.scalameta::munit:0.7.29"
//> using lib "tabby:tabby:0.2.3,url=https://github.com/bjornregnell/tabby/releases/download/v0.2.3/tabby_3-0.2.3.jar"
Add Java options which will be passed when running an application.
//> using java-opt
options
//> using javaOpt
options
//> using javaOpt "-Xmx2g", "-Dsomething=a"
Add Java properties
//> using javaProp
key=value
//> using javaProp
key
//> using javaProp "foo1=bar", "foo2"
Specify default main class
//> using main-class
main class
//> using mainClass
main class
//> using main-class "helloWorld"
Set the default Scala version
//> using scala
version+
//> using scala "3.0.2"
//> using scala "2.13"
//> using scala "2"
//> using scala "2.13.6", "2.12.16"
Manually add JAR(s) to the class path
//> using jar path
//> using jars path1, path2 …
//> using jar "/Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar"
Manually add sources to the project
//> using file hello.sc
//> using files Utils.scala, Helper.scala …
//> using file "utils.scala"
Use a specific JVM, such as 14
, adopt:11
, or graalvm:21
, or system
//> using jvm
value
//> using jvm "11"
//> using jvm "adopt:11"
//> using jvm "graalvm:21"
Sets Java home used to run your application or tests
//> using java-home
path
//> using javaHome
path
//> using java-home "/Users/Me/jdks/11"
Add Javac options which will be passed when compiling sources.
//> using javac-opt
options
//> using javacOpt
options
//> using javacOpt "source", "1.8", "target", "1.8"
Set the default platform to Scala.js or Scala Native
//> using platform
(jvm
|scala-js
|scala-native
)+
//> using platform "scala-js"
//> using platform "jvm", "scala-native"
Add a repository for dependency resolution
//> using repository
repository
//> using repository "jitpack"
//> using repository "sonatype:snapshots"
//> using repository "https://maven-central.storage-download.googleapis.com/maven2"
Manually add a resource directory to the class path
//> using resourceDir
path
//> using resourceDirs
path1, path2 …
//> using resourceDir "./resources"
Add Scala Native options
//> using nativeGc
value
//> using nativeMode
value
//> using nativeVersion
value
//> using nativeCompile
value1, value2
//> using nativeLinking
value1, value2
//> using nativeClang
value
//> using nativeClangPP
value
//> using nativeEmbedResources
true|false
//> using nativeVersion "0.4.0"
Add Scala.js options
//> using jsVersion
value
//> using jsMode
value
//> using jsModuleKind
value
//> using jsSmallModuleForPackage
value1, value2
//> using jsCheckIr
true|false
//> using jsEmitSourceMaps
true|false
//> using jsDom
true|false
//> using jsHeader
value
//> using jsAllowBigIntsForLongs
true|false
//> using jsAvoidClasses
true|false
//> using jsAvoidLetsAndConsts
true|false
//> using jsModuleSplitStyleStr
value
//> using jsEsVersionStr
value
//> using jsModuleKind "common"
Set the test framework
//> using testFramework
class_name | //> using `test-framework`
class_name
//> using testFramework "utest.runner.Framework"
Use a toolkit as dependency
//> using toolkit
version
//> using toolkit "0.1.0"
//> using toolkit "latest"