Configuring Cobertura Exclusion to Work with Maven Site

PROBLEM

The Cobertura Maven Plugin doesn’t respect the exclusion configuration. For example, if you have the following pom.xml, the exclusion configuration does absolutely nothing when you execute mvn site.

<project ...>
	...
	<reporting>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>2.5.2</version>
				<configuration>
					<instrumentation>
						<excludes>
							<exclude>**/wsdl2java/**</exclude>
						</excludes>
					</instrumentation>
					<formats>
						<format>html</format>
						<format>xml</format>
					</formats>
					<check/>
				</configuration>
			</plugin>
		</plugins>
	</reporting>
</project>

SOLUTION

To fix this, you will need to define the Cobertura Maven Plugin under both <build> and <reporting>.

<project ...>
	...
	<build>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>2.5.2</version>
				<configuration>
					<instrumentation>
						<excludes>
							<exclude>**/wsdl2java/**</exclude>
						</excludes>
					</instrumentation>
					<formats>
						<format>html</format>
						<format>xml</format>
					</formats>
					<check/>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<reporting>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>2.5.2</version>
				<configuration>
					<instrumentation>
						<excludes>
							<exclude>**/wsdl2java/**</exclude>
						</excludes>
					</instrumentation>
					<formats>
						<format>html</format>
						<format>xml</format>
					</formats>
					<check/>
				</configuration>
			</plugin>
		</plugins>
	</reporting>
</project>

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s