[ 
https://jira.codehaus.org/browse/MPMD-84?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=316327#comment-316327
 ] 

Ed Bras commented on MPMD-84:
-----------------------------

It's not fixed!
Yes, the "<excludes>" in maven works well, I use it, but the issue is about the 
<exclude-pattern> ...
But, the "<exclude-pattern>" doesn't work in a ruleset xml file (like explained 
in the url listed in the original issue).

I just tested it several times against 2.5. I changed the package pattern, 
etc... but didn't got it to work. The only way I got it to exclude to run the 
rule against the gwt pacakges was to exclude the complete file that contains 
the rulesets ;)... See below for details, I hope this helps.

Example: I use it to exclude rules against google GWT code.
My pom snippet:
-----
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-pmd-plugin</artifactId>
  <version>2.5</version>
  <configuration>
   <rulesets>
     <ruleset>../rulesets/basic.xml</ruleset>
      ....
      ....
      <ruleset>../rulesets/safeGwt.xml</ruleset>  
     </rulesets>
     <linkXref>true</linkXref>-->
     <sourceEncoding>utf-8</sourceEncoding>
     <minimumTokens>100</minimumTokens>
     <targetJdk>${java.version}</targetJdk>
     <excludes>
      <exclude>**/Assert.java</exclude>
     </excludes>
  </configuration>
  <dependencies>
   <dependency>
    <groupId>bla</groupId>
    <artifactId>project containing the rulesets in the classpath.</artifactId>
    <version>${version.ited.gen}</version>
   </dependency>
  </dependencies>
  <executions>
   <execution>
    <phase>${report.phase}</phase>
    <goals>
     <goal>check</goal>
     <goal>cpd-check</goal>
    </goals>
   </execution>
  </executions>
</plugin>
-----

And the safeGwt.xml contains (not all rules included):
----
<ruleset name="Custom ruleset" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"; 
 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0   
  http://pmd.sourceforge.net/ruleset_2_0_0.xsd";>

  <!-- Exclude the gwt packages -->
  <exclude-pattern>.*/gwt/.*</exclude-pattern>

 <rule name="NonThreadSafeSingleton" message="Singleton is not thread safe" 
   class="net.sourceforge.pmd.rules.design.NonThreadSafeSingleton"
   [... all rule details ...]
 </rule>

</ruleset>

----

                
> Maven PMD plugin does not honour exclude-pattern in PMD rulesets
> ----------------------------------------------------------------
>
>                 Key: MPMD-84
>                 URL: https://jira.codehaus.org/browse/MPMD-84
>             Project: Maven 2.x PMD Plugin
>          Issue Type: Bug
>          Components: PMD
>    Affects Versions: 2.4
>            Reporter: Denis Cabasson
>         Attachments: mpmd84-20100716.patch
>
>
> According to PMD documentation, exclude-patterns should be independendant on 
> the program running PMD :
> http://pmd.sourceforge.net/howtomakearuleset.html
> But Maven scans through all the files, not taking into account the 
> exclude-patterns and thus including files that shouldn't be.
> THose file should be filtered out by the maven plugin

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to