Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT always downloads the packages/scala libraries

Tags:

scala

sbt

I have recently installed SBT on Windows XP SP3 machine to get started with Scala. When I started it initially, it started grabbing all the JAR's from the remote locations - pretty much like Maven or any other dependency management tool.

But, whenever I change my directory and fire up sbt, it again starts downloading the entire solution. Is there a way of maintaining a global cache whereby artifacts are only downloaded once and not every time I change my working directory?

like image 213
sasuke Avatar asked Sep 16 '12 09:09

sasuke


People also ask

Where are dependencies stored in sbt?

If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically.

Does sbt use ivy?

By default, sbt uses the standard Ivy home directory location ${user. home}/. ivy2/ . This can be configured machine-wide, for use by both the sbt launcher and by projects, by setting the system property sbt.

Which is the correct way to add dependencies in sbt file?

Library dependencies can be added in two ways: unmanaged dependencies are jars dropped into the lib directory. managed dependencies are configured in the build definition and downloaded automatically from repositories.

Does sbt use coursier?

sbt 1.3. x ships with coursier support out-of-the-box, and that support is enabled by default. You shouldn't need to add sbt-coursier to sbt 1.3. x builds in most cases.


2 Answers

If you run the same version of sbt in a new directory, it will first look in the local ivy2 cache. It will still check all the resources, but will get them locally if they already exist.

However, if you are using SBT extras, it may re-download if you change to a different version of SBT, because it creates a cache for each version. That's my experience on Ubuntu in any case.

What you may have experienced is that some types of sbt plugins, for example sbt-idea, may download additional resources such as source repositories and documentation.

like image 106
Jack Avatar answered Sep 21 '22 11:09

Jack


In my case (Debian), every time I run sbt it gets files from Getting org.scala-sbt sbt 0.13.16. I was not having a local ivy2 catch. The solution was just to copy the .ivy2 folder in /root to your user home /home/username and give access permissions to user.

like image 25
Indra Avatar answered Sep 18 '22 11:09

Indra