Maven: metadata xml files downloaded often from remote repositories
Asked Answered
C

3

5

I'm using Maven to handle a Java project. I thought that Internet connectivity was only needed in the 1st compile to download the required libraries from the remote repositories, but I get several download messages whenever I compile code. Messages like these:

Downloading: http://repo.maven.apache.org/maven2/org/eclipse/core/resources/maven-metadata.xml
Downloading: http://repository.springsource.com/maven/bundles/external/org/eclipse/core/resources/maven-metadata.xml
Downloading: http://repository.springsource.com/maven/bundles/release/org/eclipse/core/resources/maven-metadata.xml
Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/eclipse/core/resources/maven-metadata.xml

Why that happens and how I could prevent it?

Conti answered 9/8, 2012 at 13:51 Comment(0)
K
4

The most important thing is to start using a repository manager furthermore check the configuration in your settings.xml file which can be configured to check the remote repositories (update policy).

Karonkaross answered 9/8, 2012 at 14:37 Comment(1)
I don't understand why Maven needs to check for updates in the first place, if the version of all my libraries are explicit in the pom.xml file. From what I've read, I just need to remember to change this option whenever I update a dependency version, otherwise the new version of the existent library won't be downloaded from the repository. I can live with that. In a perfect world, Maven would detect this update in the pom.xml and only then he would check for the newest version in repositories.Conti
H
5

This usually happens when no version information is specified for the artifact.

maven-metadata.xml is a file which contains the <groupId>, <artifactId> and the versioning information about the various versions available for the dependency.

If the version of the artifact is not specified in the pom.xml, maven downloads this metadata file to check if the local repository contains the latest version.

So, you can avoid this download by specifying the version information of the artifact in pom.xml file, instead of changing the update policy which might affect the update process of other jar files in future.

Heeling answered 13/8, 2012 at 12:50 Comment(0)
K
4

The most important thing is to start using a repository manager furthermore check the configuration in your settings.xml file which can be configured to check the remote repositories (update policy).

Karonkaross answered 9/8, 2012 at 14:37 Comment(1)
I don't understand why Maven needs to check for updates in the first place, if the version of all my libraries are explicit in the pom.xml file. From what I've read, I just need to remember to change this option whenever I update a dependency version, otherwise the new version of the existent library won't be downloaded from the repository. I can live with that. In a perfect world, Maven would detect this update in the pom.xml and only then he would check for the newest version in repositories.Conti
G
1

1) Check that you indeed have these artifacts in your local repo 2) Check your repository configuration so you are using your repos only to download releases.

<project>
    ...
    <repositories>
        <repository>
            <id>my-repo1</id>
            <name>your custom repo</name>
            <url>http://jarsm2.dyndns.dk</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    ...
</project>

3) You can force maven to only use your local repo with the -o option:

mvn -o clean package
Grunter answered 9/8, 2012 at 14:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.