scala-cli
scala-cli copied to clipboard
Add support for all kinds of JVM args via `.scala-jvmopts` file and `JAVA_OPTS` env var, not only java properties
Describe what needs to be done and why
I'm trying to run a local Spark job as a shebang script. On modern JDKs, Spark requires certain args to be provided to JVM (e.g., --add-exports java.base/sun.nio.ch=ALL-UNNAMED). The current implementation of scala-cli can only propagate java properties (using JAVA_OPTS or .scala-jvmopts), but not other vm args. I receive the following warning:
Warning: Only java properties are supported in .scala-jvmopts file. Other options are ignored: --add-exports java.base/sun.nio.ch=ALL-UNNAMED
It's not the case for sbt, for example, as it supports such kind of args both in JAVA_OPTS and in .jvmopts file.
Describe alternatives you've considered
I've considered scala-cli --power run --spark-standalone, it starts to download JDK 8, but it's not what I want.
It's not about running Spark at all costs, or inability to downgrade JVM. I believe scala-cli should be able to propagate all kinds of args to JVM.
JVM args other than Java properties indeed aren't supported in the JAVA_OPTS env at the moment, as well as in the .scala-jvmopts file.
A warning was missing for when invalid JVM args are being passed in the env vars, I linked a quick fix PR (I just add the missing warning, so it doesn't solve this feature request).
Java options can instead be passed via command line options, check the relevant doc.
scala-cli . --java-opt --add-exports --java-opt java.base/sun.nio.ch=ALL-UNNAMED