Change sbt boot and ivy dirs via environment variables

Viewed 229

Is it possible to set .sbt and .ivy2 directories via environment variables?

I can override these parameters when i run sbt like that:

sbt -Dsbt.boot.directory=/tmp/.sbt/boot -Dsbt.ivy.home=/tmp/.ivy2 version

I thought this would work:

export sbt.boot.directory=/tmp/.sbt/boot
export sbt.ivy.home=/tmp/.ivy/home
sbt version

but it doesn't work...

Second question: how can i bypass sbt config launcher? (http://www.scala-sbt.org/0.13/docs/Launcher-Configuration.html) when running sbt?

1 Answers

You can set JAVA_OPTS or SBT_OPTS environment variables with the runtime parameters for the SBT. The difference is that JAVA_OPTS effects also other Java based applications while SBT_OPTS only effects the SBT. For example:

export SBT_OPTS="-Dsbt.ivy.home=/tmp/.ivy/home -Dsbt.boot.directory=/tmp/.sbt/boot"

When you run the SBT from the command-line, it will use these parameters. However, if you launch it from IntelliJ IDEA, it will not use them. IDEA launches the SBT JAR directly and SBT's VM parameters have to be configured in the IDEA sbt settings per project.

For the second question, it is unclear what you mean by bypass. It is possible to run the SBT jar directly instead of the sbt launcher script. For example:

java -server -Xmx1536M -Dsbt.ivy.home=/tmp/.ivy/home -jar /<install-path>/sbt/bin/sbt-launch.jar
Related