Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Maven downloading the maven-metadata.xml every time?

People also ask

How do I prevent Maven from downloading artifacts every time?

In my experience, none of that works once maven has "decided" that it must download the file from an specific server. Configure updatePolicy a other suggest, but in order to suceed, you should go to the folder inside the local repository where the jar is, and delete a file named "_maven. repositories".

Why does Maven download so much?

This concept is known as "transitive dependency". Now, in order to "fill" the local repo maven has to download the jars to your local hard drive, that's why you see that it downloads a lot of stuff. So, answering your question, yes its normal maven behavior.

What is Maven metadata XML file?

The file at https://repo1.maven.org/maven2/com/octopus/randomquotes/maven-metadata.xml is created when a Maven artifact is published. It lists various details about the artifacts that have been published, like version number and the dates when the artifact was last updated.

How do I stop Maven download from Central?

In maven's home, in the conf directory is a global settings. xml . You can either set a mirror to central that points to some internal server or just override it's definition.


Look in your settings.xml (or, possibly your project's parent or corporate parent POM) for the <repositories> element. It will look something like the below.

<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. The example tells Maven to contact the remote repo (Nexus in my case, Maven Central if you're not using your own remote repo) any time Maven needs to retrieve a snapshot artifact during a build, checking to see if there's a newer copy. The metadata is required for this. If there is a newer copy Maven downloads it to your local repo.

In the example, for releases, the policy is daily so it will check during your first build of the day. never is also a valid option, as described in Maven settings docs.

Plugins are resolved separately. You may have repositories configured for those as well, with different update policies if desired.

<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 else mentioned the -o option. If you use that, Maven runs in "offline" mode. It knows it has a local repo only, and it won't contact the remote repo to refresh the artifacts no matter what update policies you use.


It is possibly to use the flag -o,--offline "Work offline" to prevent that.

Like this:

maven compile -o


I suppose because you didn't specify plugin version so it triggers the download of associated metadata in order to get the last one.

Otherwise did you try to force local repo usage using -o ?