I need to get timestamp and build number of maven artifact (using GAV coordinates) which stored in maven local repository metadata file (maven-metadata.xml) programmatically by using java. I know that i can simply parse this file, but it is a bad solution. Does anyone have any ideas? Thank you.
1 Answers
The timestamps your speak of are a feature of how Maven stores snapshot versions.
For example if the version of the artifact is 1.0-SNAPSHOT, the each call the the "install" goal will create a unique artifact referenced by its timestamp. The concept is that is another build requests the version 1.0-SNAPSHOT, Maven will return the last built artifact matching that version.
I'm not familiar with the Maven codebase, but I would suggest looking at the code that resolves versions, particularly snapshots. Possible the timestamp might be retrieveable, but I wouldn't be surprised if it's an internal detail.
Finally, I prefer to push my builds to a Maven repository manager. I find that Nexus is very lightweight and runs fine on my laptop. Long story short, Nexus has a REST API that can be used to retrieve an artifacts details, including snapshot timestamp:

- 76,015
- 10
- 139
- 185
-
Thank you for your answer. I know about Nexus's REST API. It was first way to solve my issue. But this approach wasn't quite applicable. Timestamp should be retrieve from local repository. If its not found then simply do nothing. These is feature of my issue. I think that your suggestion to look into the maven code is great idea. Sorry for my english. – hrrmsn Jan 31 '15 at 17:26