Search code examples
mavensbtivy

Why does sbt try to resolve/download artifacts I already have locally?


I live behind a corporate proxy, but I can "come up for air" and connect to a non-proxied internet if I need to for a while.

I've run update/compile cycles in sbt on my project (on the public net) and have downloaded all its dependencies into my local .ivy2 directory without problem.

Yet when I run sbt compile it still sometimes tries to re-resolve things I already "own" locally--which will hang if I try to do this behind the proxy. Why is sbt doing this?

I want to be able to work on my corporate net after being sure I've captured all my needed artifacts. Not sure if behavior is different for ivy vs maven artifacts. Happened to notice the behavior on an ivy artifact but it may affect maven pulls as well?


Solution

  • There are a two reasons this can happen:

    1. You're depending on a version that ends in -SNAPSHOT. sbt will always re-resolve this by design.
    2. You're running into an sbt bug in this area.

    sbt is quite buggy here. Older versions of sbt used to re-resolve all artifacts that had a dependency override AND were specified with the %% operator; sbt also seems to re-resolve anything that is evicted during dependency conflict resolution.

    If you see eviction warnings when compiling, try adding dependency overrides for these library versions and see if your problem persists.