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 13:59: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 (16)</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" >If you start looking at this, you
will get a headache. <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">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. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Basically
there are two ways to achive it: <br># Manual setup: manually configure Eclipse checkstyle
and pmd in your workspace <br># Automated Maven setup: update Eclipse workspace automatically
using maven profile <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Let
discuss it in details <br> <br>h5. Manual setup <br>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>h5. Automated Maven setup <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-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">wired
by pathname. Thus the following scheme. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">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. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Step
1: A project to contain the common files. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Thus
the following scheme. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">#
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;">Step
2:</span> <span class="diff-added-words"style="background-color: #dfd;">#</span>
Maven plugins use the files. <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
<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-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Step
3: Eclipse <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">#
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>
            <tr><td class="diff-unchanged" >are documented: it&#39;s all reverse
engineering. <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">In
the top level POM, there is a profile called &#39;setup.eclipse&#39;. It <br>uses
a combination of ant, xslt, and the &#39;copy&#39; task to create all of the desired
settings files. <br>Some of them are created by copying or modifying templates in etc/eclipse.
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">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: <br>{code:xml} <br>  &lt;profiles&gt;
<br>    &lt;profile&gt; <br>      &lt;id&gt;extra&lt;/id&gt;
<br>        &lt;properties&gt; <br>          &lt;gpg.useagent&gt;true&lt;/gpg.useagent&gt;
<br>	  &lt;eclipse.workspace&gt;ECLIPSE_WORKSPACE_NAME&lt;/eclipse.workspace&gt;
<br>	  &lt;downloadSources&gt;true&lt;/downloadSources&gt; <br>
  &lt;eclipse.workspace.dir&gt;ECLIPSE_WORKSPACE_PATH&lt;/eclipse.workspace.dir&gt;
<br>	  &lt;eclipse.output.directory&gt;${project.build.outputDirectory}&lt;/eclipse.output.directory&gt;
<br>	&lt;/properties&gt; <br>    &lt;/profile&gt; <br>...
<br>  &lt;/profiles&gt; <br>{code} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Eventually,
setup.eclipse runs the Maven eclipse:eclipse goal to do the vanilla work <br>of creating
.classpath and .project files for each of the projects. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Step
3: Run &#39;setup.eclipse&#39; maven profile from CXF root source folder <br>The
&#39;setup.eclipse&#39; profile uses a combination of ant, xslt, and the &#39;copy&#39;
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. <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>

<ol>
	<li>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.</li>
</ol>


<ol>
	<li>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.</li>
</ol>


<ol>
	<li>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.</li>
</ol>


<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=3&originalVersion=2">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