intellij/activator/sbt are downloading dependencies previously downloaded by the other
Asked Answered
L

2

16

I'm not an expert with sbt so probably my question is a bit noob, but I've notice than when I create a project and download its dependencies with sbt, if I open the project with intellij, all the dependencies are redownloaded again, the same happen in the inverse orden intellij->sbt and also activator..

my (poor) knowledge about sbt is than this use ivy and the dependencies are downloaded in ~/.ivy2/ folder...that is where sbt is downloading my deps, but seems than intellij is using other folder.

personally I don't use so much activator, but I would like configure sbt and intellij for use the same ivy path...

2)recently I publish finagle-postgre to my local ivy using sbt +publishLocal, I can check in my ivy folder

 /home/yo/.ivy2/local/com.twitter/finagle-postgres_2.11/0.1.0-SNAPSHOT

but unfortunately intellij is unable to resolve this dependency, I try adding this line to my build

 resolvers += Resolver.file("Local", file( Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns)

but seems not works

3) the path where is downloaded the dependencies is related to which sbt-launch.jar file is used? How can I know what sbt-lauch.jar file is using sbt right now...

thanks guys!

Leighleigha answered 30/6, 2015 at 4:17 Comment(1)
You can set the path to your local ivy repo under a project local .sbtopts file... The default is ~/.ivy2 but if you have it set to ~/.ivy2/local you'll need to update that for your build ~ See DefaultMetalepsis
S
5

If we're talking about IntelliJ appearing to download artifacts after they've already been downloaded by SBT/Activator, then it turns out that it's probably just that IntelliJ is downloading the sources - it's not redownloading the binary artifacts, just the source artifacts that accompany them.

This isn't readily apparent when you're looking at the Refreshing SBT project task in the Background Tasks popup, because the full download path is truncated, so you see something like this:

[info] downloading https://repo1.maven.org/maven2/org/apache/httpcompo...

..it's natural to assume that this is the same binary artifact you already saw SBT download on the console, but you can see the full story if you check the full log (go Help -> Show Log in files and open sbt.last.log in the file browser).

You'll see that the only artifacts getting downloaded end with -sources.jar:

$ grep repo1.maven.org /home/roberto/.IntelliJIdea2016.3/system/log/sbt.last.log 
[info] downloading https://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/4.3.6/httpclient-4.3.6-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/com/googlecode/javaewah/JavaEWAH/0.7.9/JavaEWAH-0.7.9-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/org/pegdown/pegdown/1.2.1/pegdown-1.2.1-sources.jar ...
[info] downloading https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3-sources.jar ...

```

If you don't have the Sources checkbox checked when you're doing Import project, these source downloads won't happen.

tested using IntelliJ 2016.3.5 and Scala plugin v2016.3.9

Spectroscope answered 22/3, 2017 at 9:38 Comment(1)
+1; this matches my experience. IntelliJ and SBT share a deps cache on my machine, but SBT doesn't fetch sources by default whereas IntelliJ does for me.Jumbuck
M
2

First, the activator is just a launcher for SBT itself, so there should be no difference in behaviour.

Second, IntelliJ also uses the files in ~/.ivy2 by default if you have not told it otherwise (by setting SBT_OPTS environment variable for example, but that depends on your IntelliJ version).

A difference might result if you're using different scala versions (e.g. 2.10.x vs. 2.11.x) when you do not have set the scalaVersion in your project explicitly. Then, each tool would download the corresponding libraries for the appropriate scala version it has configured by default.

Another thing is that IntelliJ will download source and javadoc jars for each dependency if you have enabled that in your settings which might look like it downloads the dependencies again.

Note, I'm wildly guessing here because you have not included any output of the programs you're using, so it's hard to say what the real problem is.

Modesta answered 19/3, 2017 at 20:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.