tags:

views:

1341

answers:

2

I recently added Maven snapshot build capability to a project, configured to use unique timestamp version on deployed artifact. But there is some confusion regarding whether this is the right thing to do (snapshots in question are deployed to one of public repos, not just within an entity like company): some say it causes problems when trying to use snapshots.

So: given how much of Maven is convention based, and following perceived best practices, I am hoping there are some guidelines as to which option to choose.

(NOTE: I slightly edited the title -- I am specifically interesting in benefits (or lack thereof) of including unique timestamp, via deploy option, for public snapshot versions; not so much whether to make use of timestamps if they are included, although that is obviously somewhat related question)

A: 

The whole point of a snapshot is to let someone use the latest version of the code. Why would you want to use a snapshot five versions back?

With that in mind, what do timestamps in the artifact name buy you?

I've been using Maven for about 5 years now. I've never seen a snapshot jar with a timestamp in the name.

Jon Strayer
Thanks!I do not know original intentions of this option, but my guess was timestamp could serve one of 2 intents:* Allow reproducible builds (specific instante of snapshot)* Ensure that the latest version is used, independent of caching or details of inter-repo synchronization (since snapshot artifact name changes, it gets (r)synced; without it there appears to be some problems)But the reason I asked was: I don't know if these are considered valid. :-)I just saw the option and have seen some projects (like Enunciate) use timestamps for their snapshots.
StaxMan
You might want to use a snapshot five versions back because that's what you tested with. Sometimes you need something newer than the last release (e.g., due to a new feature) but the next release isn't due out in time. So you pick a snapshot and test against it.
derobert
+1  A: 

As a rule you should always build against the -SNAPSHOT dependency. However, you should avoid releasing your product if it includes -SNAPSHOT dependencies. If you use the Maven Release Plug-in to automate your release it will check to make sure you are not using release plug-ins or dependencies.

But that is not always possible. In cases where I need to release something based on a snapshot build that is when I use the explicit timestamp/build number rather than the -SNAPSHOT version naming scheme.

You can automate this using the Versions Maven Plugin. It provides goals to lock and unlock snapshot versions in your POM.

bmatthews68
Thanks. In my case, I am publishing snapshots, not so much using them (at least for purposes of this question). But it does help: without timestamps in repo, you can not declare dependencies that would use them. So that would be a reason for including timestamps.
StaxMan