2
votes

I'm using Maven 3.0.5 & Nexus.

I've SNAPSHOT artifacts in a Nexus repository. These are working as expected.

The artifacts in Nexus are showing up like the following:

ArtifactID-1.1.0-20130806.104205-5.pom

This is fine. The SNAPSHOT gets expanded as a timestamp.

When I do a mvn build, the latest snapshot is retrieved as expected. Everything is working well.

The thing is, I'd like to be able to retrieve the timestamp of the resolved artifact. If I do a "mvn -X" option, all that shows up in the debug log is ArtifactId-1.1.0-SNAPSHOT, and not the timestamp.

I can't seem to be able to display which timestamp has been retreived. I could hack together some script that looks in .m2, but I'd like to know if there is a clean way to show the timestampe of the SNAPSHOT that is being used?

2

2 Answers

1
votes

Try using the Nexus REST resolve API.

The following example:

http://myrepo:8081/nexus/service/local/artifact/maven/resolve?r=central&g=log4j&a=log4j&v=1.2.6

returns:

<artifact-resolution>
  <data>
    <presentLocally>true</presentLocally>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.6</version>
    <extension>jar</extension>
    <snapshot>false</snapshot>
    <snapshotBuildNumber>0</snapshotBuildNumber>
    <snapshotTimeStamp>0</snapshotTimeStamp>
    <sha1>4bf32b10f459a4ecd4df234ae2ccb32b9d9ba9b7</sha1>
    <repositoryPath>/log4j/log4j/1.2.6/log4j-1.2.6.jar</repositoryPath>
  </data>
</artifact-resolution>

For a snapshot revision it will return the timestamp.

0
votes

maybe you can use a the dependencySet:

<outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>

I hope it helps.