Why does Maven download maven-metadata.xml every time?

The following is the error that I usually get when my internet connection is great when trying to create a web application using maven.

My question is: why maven always loads every time the same application was created earlier.

What could be wrong in my configuration, which causes maven to load every time?

The following is the error I get when I try to build offline:

[INFO] ------------------------------------------------------------------------ [INFO] Building mywebapp 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: https://raw.github.com/pagecrumb/mungo/mvn-repo/com/pagecrumb/mungo/0.0.1-SNAPSHOT/maven-metadata.xml [WARNING] Could not transfer metadata com.mywebapp:mungo:0.0.1-SNAPSHOT/maven-metadata.xml from/to mungo-mvn-repo (https://raw.github.com/pagecrumb/mungo/mvn-repo/): raw.github.com [INFO] [INFO] --- maven-war-plugin:2.1.1:war (default-cli) @ mywebapp --- [INFO] Packaging webapp [INFO] Assembling webapp [mywebapp] in [D:\workspace\web\target\mywebapp-1.0-SNAPSHOT] [INFO] Processing war project [INFO] Copying webapp resources [D:\workspace\web\src\main\webapp] [INFO] Webapp assembled in [1237 msecs] [INFO] Building war: D:\workspace\web\target\mywebapp-1.0-SNAPSHOT.war [WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored (webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true') [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building com.mywebapp [com.mywebapp] 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.1/maven-release-plugin-2.1.pom [WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.1: Plugin org.apache.maven.plugins:maven-release-plugin:2.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-release-plugin:jar:2.1 Downloading: http://download.java.net/maven/2/org/apache/maven/plugins/maven-metadata.xml Downloading: http://download.java.net/maven/2/org/codehaus/mojo/maven-metadata.xml 397/397 B Downloaded: http://download.java.net/maven/2/org/codehaus/mojo/maven-metadata.xml (397 B at 0.0 KB/sec) [WARNING] Failure to transfer org.apache.maven.plugins:maven-war-plugin/maven-metadata.xml from http://download.java.net/maven/2 was cached in the local repository, resolution will not be reattempted until the update interval of maven2-repository.dev.java.net has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins:maven-war-plugin/maven-metadata.xml from/to maven2-repository.dev.java.net (http://download.java.net/maven/2): download.java.net [INFO] [INFO] --- maven-war-plugin:2.3:war (default-cli) @ mywebapp-build --- [INFO] Packaging webapp [INFO] Assembling webapp [mywebapp-build] in [D:\workspace\target\mywebapp-build-0.0.1-SNAPSHOT] [INFO] Processing war project [INFO] Webapp assembled in [15 msecs] [INFO] Building war: D:\workspace\target\mywebapp-build-0.0.1-SNAPSHOT.war [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] mywebapp ..................................... SUCCESS [27.999s] [INFO] com.mywebapp [com.mywebapp] ..................... FAILURE [1:00.406s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1:41.409s [INFO] Finished at: Tue May 07 22:13:38 SGT 2013 [INFO] Final Memory: 11M/28M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:war (default-cli) on project mywebapp-build: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) 
+60
java maven maven-3 maven-metadata
May 7, '13 at 14:21
source share
4 answers

Look at settings.xml (or perhaps the parent or corporate parent of the project POM) for the <repositories> element. It will look something like this.

 <repositories> <repository> <id>central</id> <url>http://gotoNexus</url> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> <releases> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> </releases> </repository> </repositories> 

Note the <updatePolicy> element. In this example, Maven accesses the remote repo (Nexus in my case, Maven Central, if you are not using your own remote repo) anytime Maven needs to get a snapshot artifact during build, checking to see if there is a new copy. This requires metadata. If there is a newer copy, Maven uploads it to the local repo.

In the example for releases, the daily policy is, therefore, it will be checked during the first build of the day. never also a valid option, as described in the Maven settings files .

Plugins are allowed separately. You can have repositories configured for them, if necessary, with various update policies.

 <pluginRepositories> <pluginRepository> <id>central</id> <url>http://gotoNexus</url> <snapshots> <enabled>true</enabled> <updatePolicy>daily</updatePolicy> </snapshots> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> </pluginRepository> </pluginRepositories> 

Someone mentioned the -o option. If you use this, Maven works offline. He knows that he has only a local repo, and he will not contact the remote repo to update artifacts no matter what update policies you use.

+77
May 7 '13 at 17:26
source share
β€” -

I suppose because you did not specify the version of the plugin, so it starts downloading the related metadata to get the latest.

Otherwise, did you try to force the use of local repo using -o?

+11
May 7 '13 at 14:38
source share

Perhaps the -o,--offline "Work offline" flag is used to prevent this -o,--offline "Work offline" .

Like this:

maven compile -o

+11
Aug 05 '15 at 7:08
source share

I have not yet studied when Maven searches, but in order to get stable and reproducible builds, I highly recommend not using Maven Respositories directly, but using Maven Repository Manager, such as Nexus.

Here is a tutorial on setting up a settings file:

http://books.sonatype.com/nexus-book/reference/maven-sect-single-group.html

http://maven.apache.org/repository-management.html

0
May 7, '13 at 14:27
source share



All Articles