Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Ivy Cache Location for sbt projects in IntelliJ IDEA?

I have sbt 0.13.2 with a Scala project in IntelliJ 13.0.2.

I just want to change my default ../.ivy2/cache path.

I tried to change following entry in ../bin/sbt file in SBT installation

-Dsbt.ivy.home=D:/IvyHome/.ivy

But no luck.

enter image description here

Even in the IDE I couldn't find the place to update SBT_HOME

What would be the solution?

enter image description here

like image 770
SMPH Avatar asked May 24 '14 13:05

SMPH


People also ask

How do I clear my sbt cache?

You can use Pretty Clean to clean the all of dev tools caches including SBT. PrettyClean also cleans the SBT project's target folder.

Where is Plugins sbt in IntelliJ?

IntelliJ plugin can be found here http://confluence.jetbrains.com/display/SCA/Scala+Plugin+for+IntelliJ+IDEA or can be installed directoly from within the IDE using Settings -> Plugins dialog. Afterwards one can just do File -> New Project -> Scala -> SBT based.


3 Answers

First of all you have two SBT plugins. The version of Scala plugin you're using already supports SBT, and you don't need an extra plugin. I recommend that you start by removing the extra plugin.

Two Plugins

Remove unofficial plugin

To remove the unofficial plugin go to plugins configuration and remove the check next to the SBT plugin. This will not remove the plugin completely, but will keep it disabled.

Disable Plugin

Change the cache location

Once you have only single plugin, you can modify the location of the cache, by going to options, and searching for sbt. You should find an entry in IDE Settings.

IDE Settings

You should see the VM Parameters. Click the icon next to the input, and add -Dsbt.ivy.home=D:/IvyHome/.ivy in the last line.

Modify Settings

Click OK and restart the IDE after saving all settings.

Now you should be using the new home location (of course this is true only for the builds run from IDE, if you use SBT from console, it will still use an old home setting).

Change the cache location for SBT ran from Console

As pointed out in the paragraph above. This change will not effect SBT ran from console. This is because by default IntelliJ uses bundled SBT.

If you want to modify your Ivy home for sbt, which you run from console, you have several ways of doing that.

I think the simplest is to modify the sbtconfig.txt file in the SBT_HOME/conf/sbtconfig.txt (Windows only - on Linux you'd have to modify sbtopts).

At the end of the file add -Dsbt.ivy.home=D:/IvyHome/.ivy.

The other way would be to modify Launcher Configuration as described in the documentation

like image 139
lpiepiora Avatar answered Oct 09 '22 23:10

lpiepiora


I had the same issue with IntelliJ IDEA 14 Build 139.463.4 (Play Framework 2.2.5 project).

I followed the steps below but it did not work for me. I finally fixed the issue by adding to the VM Parameters of the SBT Runner : -Duser.home=D:/Users/myName/ .

The variable user.home is used by the SBT Launcher to build ivy-home variable.

like image 29
smbikina Avatar answered Oct 10 '22 00:10

smbikina


The answer suggesting changing IDE settings essentially changed the file .idea/sbt.xml (if you made changes for the project), or C:\Users\***\.IdeaIC14\config\options\project.default.xml (if you made changes for the IDE default regardless which project).

Therefore, you may consider putting this file in source control if you need to change it frequently. (In my case I had to switch between the Spark 1.4 and Spark 1.5 libraries, making this worthwhile.)

like image 32
soMuchToLearnAndShare Avatar answered Oct 09 '22 23:10

soMuchToLearnAndShare