//
you're reading...
Eureka!

Reporting Plugin dependencies for Maven 3.x builds

Maven 3 has been out for a bit, and of course with some changes. Other than changing versions of plug-ins and extensions, I think the biggest change has been in the way site reporting plugins are configured. Maven 3 no longer uses /project/reporting/plugins/plugin to configure report plugins. It uses /project/build/plugins/plugin[groupId=”org.apache.maven.plugins” and artifactId=”maven-site-plugin”]/configuration/reportPlugins/plugin or /project/build/pluginManagement/plugins/plugin[groupId=”org.apache.maven.plugins” and artifactId=”maven-site-plugin”]/configuration/reportPlugins/plugin.

Now, what happens to plug-in dependencies? Like when you need to introduce a resource plug-in for say the checkstyle plug-in for custom checkstyle configuration[1]. Adding dependencies to the individual reportPlugins will cause a build failure with a large exception trace! The reason – ReportPlugin[2] does not have a dependency or dependencies field. Adding dependencies to the same plug-in under /project/build/plugins/plugin or /project/build/pluginManagement/plugins/plugin does not help – the dependencies do not get carried over to the site generation phase.

The solution: add the dependencies to the site plug-in itself.

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-site-plugin</artifactId>
	<version>3.0-beta-3</version>
	<configuration>
		<generateSitemap>true</generateSitemap>
		<reportPlugins>
			<!-- See http://maven.apache.org/plugins/maven-site-plugin-3.0-beta-3/maven-3.html -->
			<!-- Other report plugins -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<configuration>
					<configLocation>infix/checkstyle/infix-checks.xml</configLocation>
				</configuration>
			</plugin>
		</reportPlugins>
	</configuration>
	<dependencies>
		<dependency>
			<groupId>com.mindtree.techworks.infix.plugins-common</groupId>
			<artifactId>infix-build-configs</artifactId>
			<version>${infix.pluginscommon.version}</version>
		</dependency>
	</dependencies>
</plugin>

It is simple… but it works šŸ™‚

[1] http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/multi-module-config.html
[2] http://svn.apache.org/viewvc/maven/plugins/tags/maven-site-plugin-3.0-beta-3/src/main/java/org/apache/maven/plugins/site/ReportPlugin.java?view=markup

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About Random Musings

Random Musings is a collection of my personal thoughts, opinions, views and anything else that I find interesting. The views posted here are mine and may not necessarily reflect the views of MindTree Limited (my employer).
%d bloggers like this: