Although the Scala CLI runner can be used as a native image and thus will not always be run on the JVM it still supports Java properties. There are a couple ways to specify them.
On the Command line
Java properties can be passed as arguments, before the sub-command name and sources, when invoking
scala-cli '-Dcoursier.credentials=maven.pkg.github.com Private_Token:gh_token1234' run .
scala-cli run . -Dfoo=barwould pass the java property into your Scala app
scala-cli -Dfoo=bar run .would pass the java property into
You can also use a
.scala-jvmopts file placed in the project's root, example file content:
It's also possible to use the
config subcommand to set the properties globally:
scala-cli --power config -i java.properties "http.proxy=188.8.131.52" "http.user=User2" "coursier.credentials=..."
Please note that if you need to modify the Java properties, you have to redefine all of them. It's not possible
to update just a single value via the
config command. Each update effectively replaces the entire Java properties
Scala CLI will also read environment variables
JDK_JAVA_OPTIONS and scan them for Java properties:
export JAVA_OPTS="-Dhttp.proxy=184.108.40.206 -Dhttp.user=User2"
-D prefix can only be dropped when writing the values to config.