Monday, March 10, 2008

Always specify a version for Maven2 plugins

For the past several months my team has been suffering a lot of downtime because our local builds fail and our Continuous Integration environment fails for what appears to be no reason. What makes these issues difficult to debug is what might fail on your machine, won't fail on mine ("works on my machine"). We eventually found the cause and that was we were not specifying a version for plugins in our maven2 poms. Pretty dumb, eh?

Wrong way

<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-surefire-plugin</artifactid>
</plugin>
Correct way
<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-surefire-plugin</artifactid>
<version>2.3</version>
</plugin>

This matters because if you leave out the version, maven2 defaults to SNAPSHOT. So what was happening is my project unknowingly became automatic beta testers for third party plugins.

So the moral of the story is always include a version (preferably a stable release version like 2.3 and not 2.3-SNAPSHOT) when defining your plugins. This will go a long ways in making your build more stable. And better yet, define those plugins in your parent pom using the <pluginManagement> section. This keeps your versions in one place so that when you do upgrade intentionally to a newer version you only have to modify it in one place for your entire project. For example:
<pluginmanagement>
<plugins>
<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-surefire-plugin</artifactid>
<version>2.3</version>
</plugin>
<plugins>
</plugins>


Specifically the maven-surefire-plugin and maven-war-plugin have cost us a lot already, so recently I updated all our poms to define a version for all the plugins we were using. And one reason I know it would fail for some, but not others, is some prefer to build in offline mode (-o) always which prevented them from seeing the problems.

4 comments:

jlorenzen said...

It seems maven 2.0.9 has resolved this issue. Check out the release notes: http://maven.apache.org/release-notes.html

Brian said...

Good write up. I provided some background and more tips on dealing with plugin versions in 2.0.9 here

Anonymous said...

Now do you worried about that in the game do not had enough wakfu kamas to play the game, now you can not worried, my friend told me a website, in here you can buy a lot wakfu gold and only spend a little money, do not hesitate, it was really, in here we had much wakfu money, we can sure that you will get the wakfu kama, quick to come here to buy wakfu kamas.

Now do you worried about that in the game do not had enough runescape gold to play the game, now you can not worried, my friend told me a website, in here you can buy a lot rs gold and only spend a little money, do not hesitate, it was really, in here we had much runescape money, we can sure that you will get the cheap rs gold, quick to come here to buy runescape.

products said...

China Wholesale has been described as the world’s factory. This phenomenom is typified by the rise ofbusiness. Incredible range of products available with China Wholesalers “Low Price and High Quality” not only reaches directly to their target clients worldwide but also ensures that wholesale from china from China means margins you cannot find elsewhere and buy products wholesaleChina Wholesale will skyroket your profits.wedding dressescheap naruto cosplayanime cosplaycheap Gemstone Jewelry