Monday, February 18, 2013

Create Aggregatable Maven Report Plugin

There are some good examples, like this and this, however they all use javadoc style and didn't include the complete pom file, nor include aggregator.



The packaging maven-plugin is to instruct maven that it is a maven plugin and thus will look for the plugin.xml in META-INF.  The maven-plugin-plugin in the build is to generate the plugin.xml.  since I am using java annotation, we'll have to add maven-plugin-annotations to the dependencies.
Then I want to build a custom report so that it will generate the aggregated version only if the project has modules (to aggregated the reports of all its modules) and the normal report when the report has no modules. to do that, annotate MavenProject with @Component and the current project will be injected. Override the canGenerateReport so that either the aggregated version or the normal version will be generated.


the reactor projects is to get the module projects for aggregated as MavenProject.getModules only return the name of the module.
Finally to add that to your site report

No comments:

Post a Comment