In Maven 3 dependency:resolve -U keeps redownloading the same maven-metadata.xml over and over
We're having a problem since moving over from Maven 2 to Maven 3: if we build with the '-U' flag, checking for artifact updates takes a lot longer compared to Maven 2. I'm not sure what Maven 2 did in this case, but it seems that Maven downloads all of the maven-metadata.xml's over and over.
I'm using the following Maven version:
$ mvn --version
Apache Maven 3.0.3 (r1080300; 2011-03-10 19:10:36+0100)
Maven home: C:\Programme\apache-maven-3.0.3
Java version: 1.6.0_18, vendor: Sun Microsystems Inc.
Java home: C:\Programme\Java\jdk1.6.0_18\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"
I have redirected the output of 'mvn dependency:resolve -U' and uploaded to http://lenni.info/dependency_resolve.log
In it you can see that the project I'm building has 142 dependencies (including transitive ones) in total, but the log has 6400 lines. This seems a lot.
An example: If you analyse the log with
cat dependency_resolve.log | grep mtcommons/maven-metadata.xml | wc -l
you can see that the maven-m开发者_C百科etadata.xml of mtcommons (an internal project, that is referenced by pretty much all our internal artifacts) is being downloaded 714 times. Now, we do have 3 repositories (managed by Nexus) and I understand that all repositories must be checked but 714 times seems much too often, isn't it? It appears Maven3 does not cache the metadata even within a single build, causing it to redownload the same files multiple times.
I can't really believe that this is Maven 3 default behaviour but suspect a configuration error on our part, possibly in Nexus, too. However, after intensive search and plenty of Googling I'm at my wit's end.
How can I make Maven download the metadata file just once per build?
https://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html#Maven3.xCompatibilityNotes-SnapshotUpdates
Looks like this is on purpose.
Let's take a step back - how slow is it? Are you mirroring external repos on a local repo? What remote maven repo manager implementation are you using? There are a number of strategies to help mitigate slowness of the maven repo manager...
精彩评论