You want to check your Java code with PMD and Checkstyle.

You know what to do, you set up some rules files.

You build with maven 2.

You know what to do, you set up the plugins.

You type at Eclipse.

Now you have trouble. You need:

a) Your Eclipse code formatting style, warning, and cleanup to be consistent with your rules.
b) Eclipse configuration for the Eclipse plugins for PMD and Checkstyle that are consistent with
your rules.

If you start looking at this, you will get a headache.

Basically there are two ways to achive it:

  1. Manual setup: manually configure Eclipse checkstyle and pmd in your workspace
  2. Automated maven setup: update Eclipse workspace automatically using maven profile

Let discuss it in details

Manual Setup

CXF contains all actual configuration files for checkstyle and PMD in buildtools project . You can install appropriate configurations manually using Eclipse Prefereneces/Checkstyle and Preferences/PMD dialogs.

Automated Maven Setup

If you've done much Eclipse configuration, you know that pathnames are a pain. Relative pathnames
can't cross Eclipse projects. Anything you can wire up via classpath is easier than anything
wired by pathname.
Luckily for you, Dan Kulp did a ton of work to make this work. You can see it in CXF, and adapt it
to your own purposes.

Thus the following scheme.

1. A project to contain the common files.
CXF has a 'cxf-buildtools' project. It contains files for the tools. For each tool, there
are two files: the XML file that configures the tool (name ends with .xml), and the more-or-less
XML file that Eclipse knows how to read to configure the Eclipse plugin. These files all live
in src/main/resources. When the builttools project builds, it just copies them to target
and bundles them into a JAR file.

2. Maven plugins use the files.
The Maven plugins, of course, feed the same core XML files to the tools. By making the buildtools artifact
a dependency of the Maven checkstyle and PMD plugins, the files become available by classpath.
This happens in the parent POM (parent/pom.xml) so that it is set up for all of the projects.

3. Eclipse.
Eclipse is configured via a collection of files that live in the .settings directories of the workspace and the individual projects. Each plugin defines the format of its settings. None of them are documented: it's all reverse engineering.

How to setup it step by step:
Step 1: Check out CXF projects on the root level.
Step 2: Create your Eclipse workspace. By default maven plugin assumes that workspace is located in ../workspace relative to root CXF source directory. To customize it, just add following xml fragment into your maven settings.xml:

  <profiles>
    <profile>
      <id>extra</id>
        <properties>
          <gpg.useagent>true</gpg.useagent>
	  <eclipse.workspace>ECLIPSE_WORKSPACE_NAME</eclipse.workspace>
	  <downloadSources>true</downloadSources>
	  <eclipse.workspace.dir>ECLIPSE_WORKSPACE_PATH</eclipse.workspace.dir>
	  <eclipse.output.directory>${project.build.outputDirectory}</eclipse.output.directory>
	</properties>
    </profile>
...
  </profiles>

Step 3: Run 'setup.eclipse' maven profile from CXF root source folder.
The 'setup.eclipse' profile uses a combination of ant, xslt, and the 'copy' task to create all of the desired settings files. Some of them are created by copying or modifying templates in etc/eclipse.
Running this profile from root CXF level will update your Eclipse workspace with necessary settings. If workspace was updated, you will be able to see cxf-checkstyle.xml and cxf-checkstyle-corba.xml files in root workspace directory.
Once it happens, it will be enough to import CXF projects generated using eclipse:eclipse or m2e plugin into workspace. Checkstyle and PMD will be automatically activated.