You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Hilco Wijbenga <hi...@gmail.com> on 2009/10/23 01:22:22 UTC

Sharing PMD rule set between maven-pmd-plugin and Eclipse PMD plugin

Hi all,

I'm trying to share the rule set definition for PMD between Maven and
Eclipse. I had hoped to create a separate Maven project which would
generate a JAR with the rule set I want to use. I had thought to add
that JAR as a dependency to maven-pmd-plugin (or as a regular
dependency) and reference it there but maven-pmd-plugin doesn't seem
to be able to find it (within a JAR). It doesn't look like the Eclipse
PMD plugin would be able to use it either.

Another option would be to use an http link (like
http://svn/xyz/ruleset.xml). That should work for maven-pmd-plugin but
it doesn't work for the Eclipse PMD plugin (AFAICT). In any event,
that would torpedo any thought of repeatable builds.

Has anyone had any luck with this or a similar set up? Any other
ideas? Or is it simply impossible?

Cheers,
Hilco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing PMD rule set between maven-pmd-plugin and Eclipse PMD plugin

Posted by Hilco Wijbenga <hi...@gmail.com>.
2009/10/22 Daniel Kulp <dk...@apache.org>:
> See:
> http://cxf.apache.org/connecting-maven-eclipse-checkstyle-and-pmd.html
> and
> http://cxf.apache.org/setting-up-eclipse.html
>
> CXF does this quite well.
>
> The "setup.eclipse" profile we have sets up the workspace with CXF code
> styles, import orders, compiler warning levels, checkstyle rules, etc....  It
> then sticks the .pmd, .ruleset, and .checkstyle files for all the projects so
> that the eclipse plugins will pick them up.

Interesting. Does it automatically handle new versions of the
PMD/Checkstyle rules?

The other developers here aren't used to Maven and probably will not
run it but use Eclipse exclusively. So I'm trying to avoid making the
Eclipse build depend on having run the Maven build first.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing PMD rule set between maven-pmd-plugin and Eclipse PMD plugin

Posted by Daniel Kulp <dk...@apache.org>.
See:
http://cxf.apache.org/connecting-maven-eclipse-checkstyle-and-pmd.html
and
http://cxf.apache.org/setting-up-eclipse.html

CXF does this quite well.

The "setup.eclipse" profile we have sets up the workspace with CXF code 
styles, import orders, compiler warning levels, checkstyle rules, etc....  It 
then sticks the .pmd, .ruleset, and .checkstyle files for all the projects so 
that the eclipse plugins will pick them up.

Dan



On Thu October 22 2009 7:22:22 pm Hilco Wijbenga wrote:
> Hi all,
> 
> I'm trying to share the rule set definition for PMD between Maven and
> Eclipse. I had hoped to create a separate Maven project which would
> generate a JAR with the rule set I want to use. I had thought to add
> that JAR as a dependency to maven-pmd-plugin (or as a regular
> dependency) and reference it there but maven-pmd-plugin doesn't seem
> to be able to find it (within a JAR). It doesn't look like the Eclipse
> PMD plugin would be able to use it either.
> 
> Another option would be to use an http link (like
> http://svn/xyz/ruleset.xml). That should work for maven-pmd-plugin but
> it doesn't work for the Eclipse PMD plugin (AFAICT). In any event,
> that would torpedo any thought of repeatable builds.
> 
> Has anyone had any luck with this or a similar set up? Any other
> ideas? Or is it simply impossible?
> 
> Cheers,
> Hilco
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing PMD rule set between maven-pmd-plugin and Eclipse PMD plugin

Posted by Brett Porter <br...@apache.org>.
On 23/10/2009, at 11:39 AM, Hilco Wijbenga wrote:

>>
>> It needs to be under <plugin>, in the <build> section (not the  
>> <reporting>
>> section, and not the <pluginManagement> section).
>>
>> Here is a working example from the Effective Implementation book:
>> http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/pom.xml
>
> Weird, that's exactly what I have. I even changed "rulesets" to "pmd"
> to match what you have (just in case). Maven doesn't find it. I'll
> have to try it at home with a smaller project.
>

A possible problem under Maven 2 is if you have multiple instances of  
the plugin declared as the classloader of the first one is always  
used. That's why the above is in the root project of all that will use  
it. You might also consider it in a organization POM (just  
configuration and deps, not executions) to ensure it is shared.

- Brett


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing PMD rule set between maven-pmd-plugin and Eclipse PMD plugin

Posted by Hilco Wijbenga <hi...@gmail.com>.
2009/10/22 Brett Porter <br...@apache.org>:
>
> On 23/10/2009, at 10:45 AM, Hilco Wijbenga wrote:
>
>> Yes, I know about this. :-) Here's what I tried and doesn't work:
>>
>> pmd-ruleset:
>> src/main/resources/rulesets/da.xml (full set of rules; this is what
>> Eclipse generates so I expect it to be okay)
>>
>> my-project pom.xml (snippets only):
>> <dependency>
>>  <artifactId>pmd-ruleset</artifactId>
>> </dependency>
>> <plugin>
>>  <artifactId>maven-pmd-plugin</artifactId>
>>  <configuration>
>>   <rulesets>
>>     <ruleset>/rulesets/da.xml</ruleset>
>>   </rulesets>
>>  </configuration>
>> </plugin>
>>
>> The plugin then complains that it can't find da.xml. I've also tried
>> it with the dependency directly under the plugin.
>>
>
> It needs to be under <plugin>, in the <build> section (not the <reporting>
> section, and not the <pluginManagement> section).
>
> Here is a working example from the Effective Implementation book:
> http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/pom.xml

Weird, that's exactly what I have. I even changed "rulesets" to "pmd"
to match what you have (just in case). Maven doesn't find it. I'll
have to try it at home with a smaller project.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing PMD rule set between maven-pmd-plugin and Eclipse PMD plugin

Posted by Brett Porter <br...@apache.org>.
On 23/10/2009, at 10:45 AM, Hilco Wijbenga wrote:

> Yes, I know about this. :-) Here's what I tried and doesn't work:
>
> pmd-ruleset:
> src/main/resources/rulesets/da.xml (full set of rules; this is what
> Eclipse generates so I expect it to be okay)
>
> my-project pom.xml (snippets only):
> <dependency>
>  <artifactId>pmd-ruleset</artifactId>
> </dependency>
> <plugin>
>  <artifactId>maven-pmd-plugin</artifactId>
>  <configuration>
>    <rulesets>
>      <ruleset>/rulesets/da.xml</ruleset>
>    </rulesets>
>  </configuration>
> </plugin>
>
> The plugin then complains that it can't find da.xml. I've also tried
> it with the dependency directly under the plugin.
>

It needs to be under <plugin>, in the <build> section (not the  
<reporting> section, and not the <pluginManagement> section).

Here is a working example from the Effective Implementation book: http://github.com/brettporter/centrepoint/blob/master/centrepoint/modules/pom.xml

- Brett


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing PMD rule set between maven-pmd-plugin and Eclipse PMD plugin

Posted by Wayne Fay <wa...@gmail.com>.
> AFAICT, the Eclipse plugin is rather limited in what it supports. I
> have only been able to add an absolute path to a rule set.

Last I checked, the PMD plugins you mentioned are both open source. So
if this isn't currently possible, tweak the code and submit a patch.
;-)

Based on your comments, it sounds like the Eclipse PMD plugin could
use some help/contributions to bring it up to par with the Maven PMD
plugin... so I'd start there.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing PMD rule set between maven-pmd-plugin and Eclipse PMD plugin

Posted by Hilco Wijbenga <hi...@gmail.com>.
2009/10/22 Brett Porter <br...@apache.org>:
> It does work as a plugin dependency, but I'm not sure about that for eclipse
> (though presumably if you have that resources project open, you can point it
> directly at the file).

AFAICT, the Eclipse plugin is rather limited in what it supports. I
have only been able to add an absolute path to a rule set.

> The example is the same as at the bottom of this page for Checkstyle:
> http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/custom-developed-checkstyle.html

Yes, I know about this. :-) Here's what I tried and doesn't work:

pmd-ruleset:
src/main/resources/rulesets/da.xml (full set of rules; this is what
Eclipse generates so I expect it to be okay)

my-project pom.xml (snippets only):
<dependency>
  <artifactId>pmd-ruleset</artifactId>
</dependency>
<plugin>
  <artifactId>maven-pmd-plugin</artifactId>
  <configuration>
    <rulesets>
      <ruleset>/rulesets/da.xml</ruleset>
    </rulesets>
  </configuration>
</plugin>

The plugin then complains that it can't find da.xml. I've also tried
it with the dependency directly under the plugin.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Sharing PMD rule set between maven-pmd-plugin and Eclipse PMD plugin

Posted by Brett Porter <br...@apache.org>.
It does work as a plugin dependency, but I'm not sure about that for  
eclipse (though presumably if you have that resources project open,  
you can point it directly at the file).

The example is the same as at the bottom of this page for Checkstyle: http://maven.apache.org/plugins/maven-checkstyle-plugin/examples/custom-developed-checkstyle.html

- Brett

On 23/10/2009, at 10:22 AM, Hilco Wijbenga wrote:

> Hi all,
>
> I'm trying to share the rule set definition for PMD between Maven and
> Eclipse. I had hoped to create a separate Maven project which would
> generate a JAR with the rule set I want to use. I had thought to add
> that JAR as a dependency to maven-pmd-plugin (or as a regular
> dependency) and reference it there but maven-pmd-plugin doesn't seem
> to be able to find it (within a JAR). It doesn't look like the Eclipse
> PMD plugin would be able to use it either.
>
> Another option would be to use an http link (like
> http://svn/xyz/ruleset.xml). That should work for maven-pmd-plugin but
> it doesn't work for the Eclipse PMD plugin (AFAICT). In any event,
> that would torpedo any thought of repeatable builds.
>
> Has anyone had any luck with this or a similar set up? Any other
> ideas? Or is it simply impossible?
>
> Cheers,
> Hilco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org