Can I change the timestamp of a snapshot to the build number?

1.7k views Asked by At

We've been seeing a bug recently where Maven tries to retrieve a SNAPSHOT that doesn't exist. As you can see the build number (whatever that is, because it's not our build number) matches, but the timestamp doesn't, causing the build to fail. This happens once in every say 20 builds.

This is in Nexus: In nexus

And this is what happens during the build:

Artifacts not found

As you can see it tries to retrieve relations-models:jar:1.1-20170901.134955-278 which doesn't exist, while 20170901.134954-278 does. Notice the offset of one second.

  1. Does anyone else have this problem? And a workaround?
  2. I was thinking of replacing the timestamp with the build number, but I can't find a way to influence how snapshots are suffixed. Does anyone know how to do that?

This concerns a (big) multi-module project, where this is one of the sub-modules.

The Jar plugin is configured like this

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <classpathPrefix>lib/</classpathPrefix>
                <mainClass>me.magnet.redirect.RedirectService</mainClass>
                <useUniqueVersions>false</useUniqueVersions>
                <classpathLayoutType>custom</classpathLayoutType
 <customClasspathLayout>$${artifact.artifactId}-$${artifact.baseVersion}.$${artifact.extension}</customClasspathLayout>
            </manifest>
        </archive>
    </configuration>
</plugin>

And the deploy plugin like this:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.8.2</version>
        <configuration>
            <uniqueVersion>false</uniqueVersion>
            <deployAtEnd>true</deployAtEnd>
        </configuration>
</plugin>

The build runs in parallel too.

1

There are 1 answers

0
Zilvinas On

Maven will try to download the latest snapshot version listed in the maven-metadata.xml file in the repository.

It sounds like you have this version listed in the maven-metadata.xml but the file is actually not there. This could possibly be due to incomplete uploaded build; if e.g. multiple modules are trying to use exact same spanshot version number, but some of them failed to compile and were not uploaded to the repo. ( also, possibly incorrect maven pom.xml configuration )