One can set adhoc Ivy home for SBT as:
# Using example directory in tmp
$ sbt -ivy /tmp/.ivy2
# Another option
$ sbt -Dsbt.ivy.home=/tmp/.ivy2/
When you use directory under ~/ (i.e. home directory) th expansion in 2nd variant will not work, i.e:
# Expansion of `~/` to home directory will not work
$ sbt -Dsbt.ivy.home=~/.ivy2-branch
You have to use $HOME
environment variable to make it work instead as:
# This is OK
$ sbt -Dsbt.ivy.home=$HOME/.ivy2-branch
Maybe this is bug in SBT launcher scripts, but expansion to $HOME
works, but ~/
doesn't.
When using ~/
the ~
directory is created in the root of project. The Ivy home resides then under that directory.
Another round of issues comes up when you try to configure different Ivy home in IntelliJ IDEA (assuming that Scala Plugin is installed).
In window Preferences > Build,Execution,Deployment > Build Tools > SBT
you can configure JVM parameters which are taken into account when SBT is run.
There is no possibility to configure -ivy
CLI option directly in IDEA.
Using absolute paths is without issues, hence typing -Dsbt.ivy.home=/tmp/.ivy2/
in VM parameters
field will do the magic.
But ... when you are trying to use user home as $HOME
or ~/
things will not work. Referring ~/
will cause the same behavior as by running SBT from command line.
Using $HOME
will be not expanded too.
There is an option to use $USER_HOME$
, which is IDEA Path Variable.
Thus using -Dsbt.ivy.home=$USER_HOME$/.ivy2-branch/
in VM parameters
form field will work.
Yet another option is to directly edit .idea/sbt.xml
file in current project directory adding the line in bold (after maximumHeapSize
)`:
<option name="maximumHeapSize" value="4096" />
<option name="vmParameters" value="-Dsbt.ivy.home=$USER_HOME$/.ivy2-branch" />
Described behavior relates to SBT version 0.13.11 and IntelliJ IDEA v 2016.1.3