Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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:

Articats 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.

like image 886
Alex Avatar asked Sep 06 '17 15:09

Alex


People also ask

What is snapshot build?

What is SNAPSHOT? SNAPSHOT is a special version that indicates a current development copy. Unlike regular versions, Maven checks for a new SNAPSHOT version in a remote repository for every build.

What is snapshot build in Maven?

A Maven snapshot is a special version of a Maven package that refers to the latest production branch code. It is a development version that precedes the final release version. You can identify a snapshot version of a Maven package by the suffix SNAPSHOT that is appended to the package version.


1 Answers

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 )

like image 95
Zilvinas Avatar answered Oct 11 '22 11:10

Zilvinas