‹‹ All posts

Scala Native compilation mode (nativeMode) via command line

15 of July, 2017

Scala Native has two linking modes:

It can just be set in build.sbt file the usual way:

nativeMode := "release"

Ideally I would not like to always use the same mode, but to keep using “debug” on local dev environment and override to “release” on CI build.

Unfortunately I didn’t find a way to achieve it without a boilerplate.

Thankfully it’s not complicated task.

Example below sets “debug” as default and allows to override it via java props, when necessary.

Allow to override default compilation mode in build.sbt via props:

nativeMode := Option(System.getProperty("nativeMode")).getOrElse("debug")

Override default at compilation in CI:

$ sbt -DnativeMode="release" compile

Use default on dev:

$ sbt compile
comments powered by Disqus