Embracing the Messiness in Search of Epic Solutions

Configuring Cobertura Exclusion to Work with Maven Site

Posted

in

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>
				</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>
				</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>
				</check></configuration>
			</plugin>
		</plugins>
	</reporting>
</project>

Comments

Leave a Reply