tags:

views:

1102

answers:

3

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.

+5  A: 

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.

Steve Moyer
It may also be updates to plugins so specifiying versions on them could also help.
Steve g
Yep ... I guess I generically included them in "dependencies". You also have to realize that lifecycle phases are often bound to specific plugins. Who actually specifies a version number for their compiler plugin?
Steve Moyer
Dependencies _must_ have a version specified. Plugins do not, but you should. Here's why: http://www.sonatype.com/people/2008/04/maven-209-released/
Brian Fox
+1  A: 

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.

Mike Deck
+1  A: 

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/%[email protected]%3E

Spencer K
This was fixed in 2.0.10: http://jlorenzen.blogspot.com/2009/04/better-offline-capabilities-with-maven.html
Brian Fox