sbtcoursier

Redownload snapshot dependency in sbt


This looks like a duplicate of Re-download a SNAPSHOT version of a dependency using SBT. However, the comments there say that

There is no need to mark SNAPSHOT dependencies as changing() because sbt configures Ivy to know this already.

I am using SBT 1.9.7, and perhaps sbt is telling Ivy, but I am clearly seeing it reference an out-of-date jar after test and then show externalDependencyClasspath. The jar is in the ~/Library/Caches/Coursier/v1/https/, so perhaps Coursier does not support this or the Ivy configuration code never got applied to Coursier.

In fact, I am finding it nearly impossible to get sbt to use the newest version of the dependency. I have deleted the directory in the cache, added and removed changing() from the dependency statement, run sbt update several times, and it is still referencing the old jar.

I looked at the Nexus server in a browser and the new version is there, right alongside the old version.

How do I get it to download the new version of the snapshot?


Solution

  • The sledgehammer solution that I found is to do this:

    In sbt, run

    show externalDependencyClasspath
    lastGrep <name of your jar>
    

    That shows all of the dependencies and then filters the output down a something that is manageable in size.

    Next, exit sbt and delete the cache. On a Mac, I found that

    rm -rf ~/Library/Caches/Coursier/v1/https/<repo-host>/repository/<group-and-artifact-id>
    

    was a reasonable level to delete.

    After that, when I started sbt, it would re-download the jar and get the latest version.