In one of my last projects on customer side I had to do a lot of Maven 3 and Tycho stuff. The customer is currently developing a new asset management software. While previous releases were written in C++ the new version to be published soon is based on JavaEE (JBoss AS) on server side and has an Eclipse RCP Client. So I was asked to move the current PDE/Build to Tycho and to support the development team while establishing the Maven build process.
Last but not least I had to include a wide range of reporting plugins, like PMD, Findbugs, Checkstyle, JDepend and so on. With the help of the article “Adding FindBugs and DRY(CPD) Reporting to Maven3/Tycho” bye David Carver I was able to get the Findbugs plugin working. But neither the PMD plugin nor Checkstyle plugin have produced any results. We didn’t get any exception or error code and so we didn’t know where to start searching for reasons.
After a certain amount of time the idea to start Maven with debug option came to my head. So I started mvn -X pmd:check and the debug output looked like the following (stripped to the relevant part):
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-pmd-plugin:2.5:pmd' with basic configurator --&amp;amp;gt;
[DEBUG] (f) aggregate = false
[DEBUG] (f) format = xml
[DEBUG] (f) includeTests = false
[DEBUG] (f) linkXRef = true
[DEBUG] (f) minimumPriority = 5
[DEBUG] (f) outputDirectory = /Users/martin/Workspaces/xxx/yyy/target/site
[DEBUG] (f) project = MavenProject: abc:1.0.4 @ /Users/martin/Workspaces/xxx/yyy/pom.xml
[DEBUG] (f) reactorProjects = [MavenProject: abc:1.0.4 @ /Users/martin/Workspaces/xxx/yyy/pom.xml]
[DEBUG] (f) skip = false
[DEBUG] (f) targetDirectory = /Users/martin/Workspaces/xxx/yyy/target
[DEBUG] (f) testSourceRoots = [/Users/martin/Workspaces/xxx/yyy/src/test/java]
[DEBUG] (f) xrefLocation = /Users/martin/Workspaces/xxx/yyy/target/site/xref
[DEBUG] (f) xrefTestLocation = /Users/martin/Workspaces/xxx/yyy/target/site/xref-test
[DEBUG] -- end configuration --
In line #4 you can see the simple reason for not getting any results from PMD. By default Maven uses src/main/java directory for locating source files. Because the customer has started to develop Eclipse RCP aká Plug-In projects all sources reside in src/ directory by default.
After adjusting the source code directory in parent pom.xml all went fine and the PMD plugin and Checkstyle plugin found sources to process.
You may ask: Why the PMD plugin wasn’t working properly, while Findbugs was? The answer is simple: Findbugs analyzes Java bytecode, also known as compiled Java classes. It doesn’t need any source files to work. PMD and Checkstyle both work with source files.
I hope this little article will help you getting your Maven plugins to work.
This post is also available in: Englisch