Question

When I launch the "mvn install" command, maven sometimes tries to download dependencies that it has already downloaded. That's expected for SNAPSHOT but why does maven do that for other JARs?

I know I can avoid that behavior by "-o" flag but I just wonder what the cause is.

Was it helpful?

Solution

I'd look for dependencies that don't have a specified version number. Maven will periodically check to make sure that it has the most up-to-date version of these artifacts.

OTHER TIPS

This is probably not what you're seeing, but in the past I've had to manually install artifacts into my local repository and if you forget to include the -Dgenerate.pom=true option there will be no pom in the repo for that artifact and Maven will go out to central (and any other remote repos you have configured) to try to download that pom on every build.

While we're on the subject of this, I've run into a major bug in Maven 2.0.x. In offline mode, maven will still attempt to download the latest snapshot, and when it can't find your snapshot repo, it fails the build. Imagine the hilarity that ensues when this happens on site with a client and you just needed to make a small change (but I digress).

Here's the bug: http://jira.codehaus.org/browse/MNG-2433 here's a workaround: http://mail-archives.apache.org/mod_mbox/maven-users/200601.mbox/%3C117228810601130559l7e79a5e2k@mail.gmail.com%3E

The -o flag still wasn't working for me, but this did:

find ~/.m2/repository -name '_maven*' | xargs rm
find ~/.m2/repository -name '*lastUpdated' | xargs rm

Which will delete all the .lastUpdated and _maven.repositories files in your local repo. I ran into this issue because we have a corporate Nexus repo that was unreachable, and I needed to do some work. Using Eclipse's Maven integration may have also contributed to this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top