| Site Generation in Maven 3 |
|
|
|
| Tuesday, 12 October 2010 15:35 |
|
So Maven 3 has finally been released, with a host of improvements and significant rework under the hood. Maven 3 is largely backward compatible with Maven 2, so migration from Maven 2 to Maven 3 is usually a very easy process. In this article, we will take a look at the one area where you may have some work to do in the migration process: site generation. In many ways, this is a very discreet release, with few apparent major new features. However, under the hood it's a different story. The internal architecture of Maven 3 has pretty much been completely rewritten, with Guice as it's IOC framework, and with clean integration points to allow smooth interaction with third-party systems such as IDEs and CI servers. Given this almost-total rewrite of the Maven internals, the extremely high backward compatibility that Maven 3 shows is truly impressive. Performance is a big feature of this new release, both in terms of general performance, and with the new ability to build modules in parallel, which can be very useful for large, multi-module builds. Maven 3 is more strict about Maven best practices, and will grumble if you don't define version numbers for your plugins or dependencies (as of course you should). One more significant difference however is site generation. You might use the Maven site generation useful as a central point of documentation about your project, or you may use it simply to generate reports and code quality metrics for use in CI servers such as Hudson or TeamCity. In either case, the mvn site command can come in very handy. If you have been using the
This won't work in Maven 3. Instead, you will have to integrate your reports into the
So you are basically just moving your old reporting plugins into the Maven 3 generally produces better console output than Maven 2, and reporting is no exception. At the end of the mvn site output, you get a nice summary of the reports generated:
All in all, a pretty straight-forward migration path. One final comment on Maven site generation might be worth noting - when it first came out, the Maven-generated technical web site was revolutionary. However, nowadays there are other tools that build on Maven's powerful reporting features to take things even further - CI servers like Hudson and TeamCity can make use of the XML reports generated by Maven to provide code quality metrics of their own, and Sonar can even run code quality metrics reporting on any Maven project, without needing to configure the project at all. All these options are worth considering when you try to introduce code quality reporting into your project.
Bookmark
Email this
Trackback(0)
Comments (7)
![]() written by Ben, October 12, 2010
Hmm, but I wonder if they have fixed multi module site links. That's been a problem since first release of 2.0.
written by Dev Stonez, October 13, 2010
Should the version for the reporting plugins be specified directly (as in Maven 2) or it will be inherited this time from ?
written by Dev Stonez, October 13, 2010
... continued from above (due to the un-escaped angles, the content was treated as a html tag)...
... inherited this time from written by Dev Stonez, October 13, 2010
it happened again (brrrr !
), so here is the actual content (last try): ============================================ Should the version for the reporting plugins be specified directly (as in Maven 2) or it will be inherited this time from "pluginManagement" ? In Maven 2 it was a bit problematic since the reporting plugins versions should be explicitely done in "reporting" section. I expect now, with Maven 3, to have this fixed, to allow version definition in "pluginManagement" section, similar to other plugins. written by Tulio Domingos, November 12, 2010
Great post! I just migrated from Maven 2 and was wondering what happened to the reporting section..Cheers
Tulio http://tuliodomingos.blogspot.com/ written by Flávio Silva, December 31, 2010
I could finally generate my project's site!!
many thanks to share that, it was so many hours figuring out how to do, but the documentation of the new 3 version is still not as wide and could only find about version 2... perfect now...
written by Kannan, April 30, 2011
Thanks for clear instructions. I could get site generated with Maven 3.0.2. The info in maven wiki was also useful, https://cwiki.apache.org/MAVEN/maven-3x-and-site-plugin.html#Maven3.xandsiteplugin-Usingmavensiteplugin2.xwithMaven2.xandmavensiteplugin3.xwithMaven3.x.
Write comment
|
In this slideshow you will learn how automated web tests can:
|