Showing posts with label Maven3. Show all posts
Showing posts with label Maven3. Show all posts

Tuesday, January 10, 2012

Checkstyle suppression configuration in Maven

Recently I ran into this checkstyle configuration problem. Basically we have this multi-module maven project and we would like to put checkstyle config and suppression in the parent maven pom but apparently checkstyle maven plugin not very happy with the relative path of suppression config file, for example


<suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
<suppressionsLocation>config/checkstyle-suppressions.xml</suppressionsLocation>

During the build modules look for checkstyle-suppressions.xml at its own directory not parent and checkstyle plugin just simply ignores the error when file not found. Some people had the same problem with me on Stackoverflow and here too. I just choose the easy solution to add a new property in both parent and children pom files to set the correct location of the config file. 

parent pom

<suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
<suppressionsLocation>${main.basedir}/config/checkstyle-suppressions.xml</suppressionsLocation>

<main.basedir>${project.basedir}</main.basedir>

children pom
<main.basedir>${project.basedir}/..</main.basedir>

And there is another way, I guess the better one, to share resource across project in Maven here.

Wednesday, August 24, 2011

Maven surefire plugin and failsafe plugin

In my previous projects, we have been using surefire plugin for both unit test and integration test because we don't really have any housekeeping after integration-test phase in the build.

I just realized today that we should have used failsafe plugin rather than surefire for integration test. To use failsafe plugin add below into your project pom.xml


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.9</version>
<configuration>
<includes>
<include>Sample.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-functional-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/*IntegrationTest.java</include>
<include>**/selenium/**/*Test.java</include>
</includes>
<excludes>
<exclude>none</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>



If you want to make your build success even with integration test fail just remove the "verify" goal and execution.