Could not find metadata in local

2020-05-25 06:52发布

问题:

Locally on the machine i have an Artifactory installed with maven repositories, and i have a very simple .pom file for my project which points to it:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>MYGROUP</groupId>
    <artifactId>NAME</artifactId>
    <packaging>jar</packaging>
    <version>VERSION</version>
    <build>
        <sourceDirectory>SRCFOLDER</sourceDirectory>
        <testSourceDirectory>TESTFOLDER</testSourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>

    </build>

    <repositories>
        <repository>
            <id>local-artifactory</id>
            <name>Artifactory</name>
            <url>http://localhost:8081/artifactory/repo</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>warn</checksumPolicy>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>local-artifactory-plugins</id>
            <name>Artifactory Plugins</name>
            <url>http://localhost:8081/artifactory/repo</url>
        </pluginRepository>
    </pluginRepositories>

<dependencies>
    <dependency>
        <groupId>MYGROUP</groupId>
        <artifactId>DEPENDENCY1</artifactId>
        <version>bla-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>MYGROUP</groupId>
        <artifactId>DEPENDENCY2</artifactId>
        <version>bla-SNAPSHOT</version>
        <scope>compile</scope>
    </dependency>
</dependencies>
</project>

So i have local-artifactory repository declared with the intention that it will reload everything every time. Also i have couple of dependencies which are SNAPSHOTS.

Now i'm using maven 3.0.5, and when i'm compiling it it works fine, but it's not refreshing snapshots at all. Never. Ever. Log file looks like this:

[DEBUG] Could not find metadata MYGROUP:DEPENDENCY1:bla-SNAPSHOT/maven-metadata.xml in local (/opt/myuser/.m2/repository)
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://localhost:8081/artifactory/repo
Downloading: http://localhost:8081/artifactory/repo/MYGROUP/DEPENDENCY1/bla-SNAPSHOT/maven-metadata.xml
Downloaded: http://localhost:8081/artifactory/repo/MYGROUP/DEPENDENCY1/bla-SNAPSHOT/maven-metadata.xml (314 B at 13.9 KB/sec)
[DEBUG] Writing resolution tracking file /opt/myuser/.m2/repository/MYGROUP/DEPENDENCY1/bla-SNAPSHOT/resolver-status.properties
[DEBUG] Could not find metadata MYGROUP:DEPENDENCY1:bla-SNAPSHOT/maven-metadata.xml in local (/opt/myuser/.m2/repository)
[DEBUG] Skipped remote update check for MYGROUP:DEPENDENCY1:bla-SNAPSHOT/maven-metadata.xml, already updated during this session.

So it constantly complains that it can't find local maven-medatada.xml and of course he's completely right - it's not there. And fails to do ANYTHING with it.

So i've tried to use dependency:purge-local-repository to purge local inventory and guess what? Apparently it can't purge it because there is no maven-metadata.xml in each artifact, what an amazing functionality!

Each .m2 artifact directory apart of .jar and .pom contains maven-metadata-local-artifactory.xml(with the correct copy of maven-metadata.xml from the artifactory, current), _mave.repositories and resolver-status.properties.

Maven is just out of the box, there is no configuration in .m2 and the configuration in the /conf folder is default without any single change.

UPDATE: I've just manually downloaded maven-metadata.xml from the artifactory and placed it as maven-metadata.xml inside .m2 for a dependency - no effect, it is still "missing" it. So i don't have any idea what it wants from me anymore. It just can't update dependencies because "already updated during this session". Well i don't know what it updated exactly, but apparently something else.

UPDATE2: Contents of maven-metadata.xml on the server:

<metadata>
    <groupId>MYGROUP</groupId> 
    <artifactId>DEPENDENCY1</artifactId> 
    <version>bla-SNAPSHOT</version> 
    <versioning>
        <snapshot>
            <buildNumber>1</buildNumber> 
        </snapshot>
        <lastUpdated>20130322155759</lastUpdated> 
    </versioning>
</metadata>

回答1:

From the maven metadata xml file it looks like you are using non-unique snapshot in your repository. Maven 3 does not supports non-unique, only snapshot pom file with TIMESTAMP-BUILDNUMBER instead of SNAPSHOT. Do you have:

http://localhost:8081/artifactory/repo/MYGROUP/DEPENDENCY1/bla-SNAPSHOT/DEPENDENCY1-bla-XXXXX-Y.pom

file?



回答2:

My maven complained that it can not find metadata in local, blah blah... and basically, what happened is that i managed to unplug my power cable in mid-maven-build and its metadata in the relevant local .m2 subdirectory got corrupted. I went in, deleted the artifacts in question from from their .m2 location and re-tried the build. All worked fine. Just wanted to leave this message for those that have a similar problem to mine, but stumbled upon your question.