Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Ivy cache directory per-user or system-wide?

Tags:

scala

sbt

ivy

I am using SBT as my build tool for building a Scala project.

My problem is, I can't configure SBT to download dependencies to my user home directory. Therefore I am looking for a per-user or even better a system-wide setting to tell SBT to put the Ivy cache directory somewhere else.

With maven there is the per-user settings.xml that can be used to configure the local repository.

I have read question How to override the location of Ivy’s Cache? and it's answers, but it seems it only describes how to configure the setting on a per project basis.

If there is no alternative I would go for a per-project setting, but I didn't get the answer from the mentioned question to work. Some more details would be most welcome, for example where to put the ivysettings.xml. I put it into the project's root directory and it didn't work.

like image 528
Ruediger Keller Avatar asked Jun 29 '10 16:06

Ruediger Keller


1 Answers

The sbt.ivy.home property is only half of the solution. It controls where the sbt launcher downloads sbt itself (and related dependencies like the scala compiler and library, etc.) As noted by Joachim Hofer, it has no effect on where the dependencies declared by your project get downloaded.

To change that location, you must set the ivy.home property. So, to augment Joachim's first solution, you would set both system properties:

java -Dsbt.ivy.home=/tmp/.ivy2/ -Divy.home=/tmp/.ivy2/ -jar `dirname $0`/sbt-launch.jar "$@" 

With these properties, the launcher will download both your project's and sbt's dependencies to the /tmp/.ivy2/ directory. Of course, you can put them in separate directories as well.

like image 62
Mark Tye Avatar answered Sep 19 '22 16:09

Mark Tye