cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF > Connecting Maven, Eclipse, Checkstyle, and PMD
Date Sat, 10 Mar 2012 14:00:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/15/_/styles/combined.css?spaceKey=CXF&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF/Connecting+Maven%2C+Eclipse%2C+Checkstyle%2C+and+PMD">Connecting
Maven, Eclipse, Checkstyle, and PMD</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~ashakirin">Andrei
Shakirin</a>
    </h4>
        <br/>
                         <h4>Changes (5)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >Let discuss it in details <br>
<br></td></tr>
            <tr><td class="diff-changed-lines" >h5. Manual <span class="diff-changed-words"><span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">s</span><span
class="diff-added-chars"style="background-color: #dfd;">S</span>etup</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >CXF contains all actual configuration
files for checkstyle and PMD in [buildtools project | http://svn.apache.org/repos/asf/cxf/build-utils/trunk/buildtools].
You can install appropriate configurations manually using Eclipse Prefereneces/Checkstyle
and Preferences/PMD dialogs. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >h5. Automated Maven <span class="diff-changed-words"><span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">s</span><span
class="diff-added-chars"style="background-color: #dfd;">S</span>etup</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >If you&#39;ve done much Eclipse
configuration, you know that pathnames are a pain. Relative pathnames <br>can&#39;t
cross Eclipse projects. Anything you can wire up via classpath is easier than anything  <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >Thus the following scheme. <br>
<br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">#</span>
<span class="diff-added-words"style="background-color: #dfd;">1.</span> A project
to contain the common files. <br></td></tr>
            <tr><td class="diff-unchanged" >CXF has a &#39;cxf-buildtools&#39;
project. It contains files for the tools. For each tool, there <br>are two files: the
XML file that configures the tool (name ends with .xml), and the more-or-less <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >and bundles them into a JAR file.
<br> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">#</span>
<span class="diff-added-words"style="background-color: #dfd;">2.</span> Maven
plugins use the files. <br></td></tr>
            <tr><td class="diff-unchanged" >The Maven plugins, of course, feed
the same core XML files to the tools. By making the buildtools artifact <br>a dependency
of the Maven checkstyle and PMD plugins, the files become available by classpath. <br>This
happens in the parent POM (parent/pom.xml) so that it is set up for all of the projects. <br>
<br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">#</span>
<span class="diff-added-words"style="background-color: #dfd;">3.</span> Eclipse
<br></td></tr>
            <tr><td class="diff-unchanged" >Eclipse is configured via a collection
of files that live in the <br>.settings directories of the workspace and the individual
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>You want to check your Java code with PMD and Checkstyle.</p>

<p>You know what to do, you set up some rules files.</p>

<p>You build with maven 2.</p>

<p>You know what to do, you set up the plugins.</p>

<p>You type at Eclipse.</p>

<p>Now you have trouble. You need:</p>

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

<p>If you start looking at this, you will get a headache.</p>

<p>Basically there are two ways to achive it:</p>
<ol>
	<li>Manual setup: manually configure Eclipse checkstyle and pmd in your workspace</li>
	<li>Automated Maven setup: update Eclipse workspace automatically using maven profile</li>
</ol>


<p>Let discuss it in details</p>

<h5><a name="ConnectingMaven%2CEclipse%2CCheckstyle%2CandPMD-ManualSetup"></a>Manual
Setup</h5>
<p>CXF contains all actual configuration files for checkstyle and PMD in <a href="http://svn.apache.org/repos/asf/cxf/build-utils/trunk/buildtools"
class="external-link" rel="nofollow">buildtools project </a>. You can install appropriate
configurations manually using Eclipse Prefereneces/Checkstyle and Preferences/PMD dialogs.</p>

<h5><a name="ConnectingMaven%2CEclipse%2CCheckstyle%2CandPMD-AutomatedMavenSetup"></a>Automated
Maven Setup</h5>
<p>If you've done much Eclipse configuration, you know that pathnames are a pain. Relative
pathnames<br/>
can't cross Eclipse projects. Anything you can wire up via classpath is easier than anything
<br/>
wired by pathname. <br/>
Luckily for you, Dan Kulp did a ton of work to make this work. You can see it in CXF, and
adapt it<br/>
to your own purposes.</p>

<p>Thus the following scheme.</p>

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

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

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

<p>How to setup it step by step:<br/>
Step 1: Check out CXF projects on the root level<br/>
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:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
  <span class="code-tag">&lt;profiles&gt;</span>
    <span class="code-tag">&lt;profile&gt;</span>
      <span class="code-tag">&lt;id&gt;</span>extra<span class="code-tag">&lt;/id&gt;</span>
        <span class="code-tag">&lt;properties&gt;</span>
          <span class="code-tag">&lt;gpg.useagent&gt;</span>true<span
class="code-tag">&lt;/gpg.useagent&gt;</span>
	  <span class="code-tag">&lt;eclipse.workspace&gt;</span>ECLIPSE_WORKSPACE_NAME<span
class="code-tag">&lt;/eclipse.workspace&gt;</span>
	  <span class="code-tag">&lt;downloadSources&gt;</span>true<span class="code-tag">&lt;/downloadSources&gt;</span>
	  <span class="code-tag">&lt;eclipse.workspace.dir&gt;</span>ECLIPSE_WORKSPACE_PATH<span
class="code-tag">&lt;/eclipse.workspace.dir&gt;</span>
	  <span class="code-tag">&lt;eclipse.output.directory&gt;</span>${project.build.outputDirectory}<span
class="code-tag">&lt;/eclipse.output.directory&gt;</span>
	<span class="code-tag">&lt;/properties&gt;</span>
    <span class="code-tag">&lt;/profile&gt;</span>
...
  <span class="code-tag">&lt;/profiles&gt;</span>
</pre>
</div></div>

<p>Step 3: Run 'setup.eclipse' maven profile from CXF root source folder<br/>
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.<br/>
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.<br/>
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.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF/Connecting+Maven%2C+Eclipse%2C+Checkstyle%2C+and+PMD">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=105238&revisedVersion=4&originalVersion=3">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF/Connecting+Maven%2C+Eclipse%2C+Checkstyle%2C+and+PMD?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message