Question

We are hosting a simple maven repository internally but maven does not seem to pick up new snapshot versions from it. Our local maven repository is configured in settings.xml with:

<snapshots>
    <enabled>true</enabled>
    <updatePolicy>always</updatePolicy>
</snapshots>

Combine this with something like "mvn -U" and I would expect maven to pick up the latest snapshot version if applicable. As I gather, maven will check the last modified of the metadata.xml and determine from that whether or not the snapshot is updated. However I'm not entirely clear as to which last updated that is. Take for example the following metadata.xml:

<metadata>
<groupId>com.example</groupId>
<artifactId>example-test</artifactId>
<version>1.0-SNAPSHOT</version>
<versioning>
    <versions>
        <version>1.0-SNAPSHOT</version>
    </versions>
    <snapshot>
        <timestamp>20120427.113221</timestamp>
        <buildNumber>1335519141810</buildNumber>
    </snapshot>
    <lastUpdated>20120427113221</lastUpdated>
</versioning>

Does maven use the lastUpdated tag? The "last-modified" http header? The snapshot.timestamp tag or something else still?

Anyway, the behavior that we are seeing is that it will indeed download the latest metadata.xml but stops there, it does not redownload the snapshot itself.

EDIT: I have noticed that the unique snapshot feature that was optional in maven 2 has become mandatory in maven 3. Is it possible that maven is simply not detecting the updated version? Check out the maven-metadata.xml from the module now:

<metadata modelVersion="1.1.0">
<groupId>com.example</groupId>
<artifactId>example-test</artifactId>
<version>1.0-SNAPSHOT</version>
<versioning>
    <snapshot>
        <timestamp>20120607.154257</timestamp>
        <buildNumber>1339076577</buildNumber>
    </snapshot>
    <lastUpdated>20120607154257</lastUpdated>
    <snapshotVersions>
        <snapshotVersion>
            <extension>jar</extension>
            <value>1.0-20120607.154257-1339076577</value>
            <updated>20120607154257</updated>
        </snapshotVersion>
    </snapshotVersions>
</versioning>

Does maven check the build number? The "updated" tag of the snapshotVersion?

Was it helpful?

Solution

If you are working on a module locally and have run:

mvn clean install

This will have installed a copy in your local Maven repository. This artifact will be in a locked state -- meaning -- it will not be updated from the remote location unless the metadata*xml has been removed.

This is a pain in the ass, if in a couple of days you're done with your work on this module and start working on some other module, which in turn depends on this initial module, as it won't pick up the changes from the your remote repository.

There has been a bug filed for this here. However, it's unlikely to be fixed anytime soon. Therefore, it's essential to know about this behavior.

OTHER TIPS

In the end, the problems were with the metadata.xml. If a model 1.1.0 is generated by our server like mentioned in the originel request, maven will only update metadata. By switching back an older "1.0.0" model, it works. Example metadata.xml:

<metadata modelVersion="1.0.0">
<groupId>com.example</groupId>
<artifactId>example-test</artifactId>
<version>1.0-SNAPSHOT</version>
<versioning>
    <snapshot>
        <timestamp>20120608.103301</timestamp>
        <buildNumber>1339144381</buildNumber>
    </snapshot>
    <lastUpdated>20120608103301</lastUpdated>
</versioning>

Whether the faulty 1.1.0 metadata.xml is an error in maven or in our repo is unknown at this time, but at least we can continue working.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top