That's one small step for Maven, a giant leap for Continuous Delivery

More than a decade ago, when I was first been introduced with Maven, I had one big issue with its concept: along side with all its benefits (and there are many as such), I didn't like the idea that for each version of my product I need to set the version of it inside the pom.xml file and save the file (with the version text inside it) as part of my code.
This concept were against any understanding I have about versioning methodologies and it caused me to actually dislike Maven. Maven 3.2.1 introduced, for the first time, a small feature that turn all the written above upside-down.

Continuous delivery friendly versions

By reading the release notes of version 3.2.1 you may not notice the below naive text which doesn't really reflect the effect of the feature:


Continuous delivery friendly versions (MNG-5576)

A simple change to prevent Maven from emitting warnings about versions with property expressions. Allowed property expressions in versions include ${revision},${changelist}, and ${sha1}. These properties can be set externally, but eventually a mechanism will be created in Maven where these properties can be injected in a standard way. For example you may want to glean the current Git revision and inject that value into ${sha1}. This is by no means a complete solution for continuous delivery but is a step in the right direction.


This 'simple change' were added indeed to prevent the following error when you use properties as part of your version:


The project com.xxx:yyy:${revision}-SNAPSHOT (yyy/pom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for com.xxx:zzz:jar must be a valid version but is '${revision}-SNAPSHOT'.


Giant leap...

But now - since Maven 3.2.1 - you can AT LAST put such properties inside your pom.xml files and enable passing the value of it as build argument.

Here's an example of how I've used it (successfully):


- mvn versions:set versions:update-child-modules -DnewVersion=1.0-$\{revision\}-SNAPSHOT
- mvn install -Drevision=B111


The build produces artifacts versioned as 1.0-B111-SNAPSHOT without changing the pom.xml files so there is no code change.

So what?

At first look, this may look as a small change, but it is indeed - as titled in the release notes - continuous delivery (and much more) friendly feature.

At last we don't need to find workaround for automating the version string and the SCM which comes as a result of it.


 


Yoram Michaeli 

@yorammi

yorammi@tikalk.com


 



 

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com