JS Ext

Friday, September 21, 2012

Maven snapshots vs milestones

Maven versions come in two flavors: snapshots and milestones.  Snapshots have a version but end in -SNAPSHOT or -LATEST.  Everything else falls into the milestone category.  Milestones are unmodifiable.  Snapshots can be changed.

When a new snapshot is created, the -SNAPSHOT gets replaced with a unique timestamp with a counter.  Parts of maven support depending directly on the "locked snapshot" version, but some maven mojos don't support that.  Pom files that depend on snapshots do not get updated to the locked snapshot.  This has a major disadvantage that artifacts that contain snapshots are not reproduceable.  Pom files that only depend on milestones are reproduceable but converting a pom file from a snapshot to a milestone can be quite painful.

Let's assume you have a large dependency tree of pom files.  Let's say 5 pom files deep.  If the bottom of the tree needs to be updated, then you have to update 4 pom files to point to the snapshot versions of the dependencies.  Once you perform all the builds, you can test your code.  Let's assume everything tested correctly.  Its time to install the code into production.  Hold on a second!  You can't install an artifact into production that isn't reproducable!  You have to milestone the bottom artifact.  Then you have to update the pom file that depends on it to use the milestones version of the dependency.  Then you have to milestone that pom.  You have to continually do this all the way up the dependency tree.  That is kind of a pain when your code has already been tested!

In my opinion, milestones should also be pointers.  These pointers should be immutable.  Pom files should be updated to point to the version that any symlinks point to during the deploy process to the remote repository.  Maven also needs better support for locked snapshots.  These changes should make every snapshot build reproduceable.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.