Sunday, July 10, 2011

Upgrading to Maven 3

In my previous post, I discussed about what is Maven 3, reasons to migrate to Maven 3 and some of it's features. I tried upgrading to Maven 3 in some of our projects and for those projects, these are the following changes that I had to do to migrate to Maven 3.

  • Reporting Section - In Maven 2, all report configuration was under top level reporting section. But, in Maven 3, these configurations have to be moved under reportPlugins in maven site plugin configuration.
  • Report configuration does not apply to build - In Maven 2, we used to have PMD/Checkstyle/Cobertura plugin configurations in report configuration and it also took effect during the build. But, this is not the case anymore in Maven 3. So, I had to move these configurations to build section for them to take effect.
  • Maven 3 needs "project." prefix for groupId, artifactId etc., In Maven 2, the prefix was not required, but now in Maven 3, because of stricter POM validation, it is necessary to add this prefix.
  • Maven versions plugin needs reportSets configured - With Maven 2, it produced default reports, but with Maven 3, I had to add reportSets section and needed to add the necessary reports under that.
  • Needed to upgrade maven site plugin from 2.2 to 3.0-beta-2 to make it work with Maven 3.
  • Needed to upgrade maven findbugs plugin from 2.3.1 to 2.3.2-SNAPSHOT to make it work with Maven 3.

After doing these changes, I could do "mvn clean install" for our project, which ran PMD/Checkstyle/Findbugs/Cobertura analysis fine and also ran tests properly. Also, did "mvn clean site" and could confirm that the site was generated properly like before.

In your project, based on the plugins that you use, there could be other changes involved. Look at the plugin compatibility notes and plugin compatibility matrix for more information. But, the above changes should work for most users.

These are the changes needed to be done in the POM. Once the POM is changed, upgrading to Maven 3 for other developers in the rest of the team is very easy. All they have to do is download Maven 3, unzip it and change M2_HOME to point the new Maven 3 install directory. That's it!

5 comments:

Anil Kumar Singh said...

Hi great info thanks for share.

Anonymous said...

hi grateful

Unknown said...

Again... thank you for the post. As a rule, I follow every entry you publish. Should the changes work for most users? The most reputable and trustworthy online proofreading services are open 24/7 to give you a helping hand when it's needed!

paulchabot said...

Thanks for that, really simple!

Blogger said...

Are you looking to earn cash from your websites with popunder ads?
In case you do, did you ever use PropellerAds?