[
https://issues.apache.org/jira/browse/MPMD-243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16317942#comment-16317942
]
Andreas Dangel commented on MPMD-243:
-------------------------------------
Hi [~britter], the problem here seems to be the different ways, maven plugins
can be configured:
The {{<configuration>}} part can be directly under {{<plugin>}} - then it apply
for all execution configurations and all goals. Or it can be under a specific
{{<execution>}}, then it applies only for this specific execution. In your
example, it applies for the execution, which executes the check goal.
Each execution also has an {{<id>}}, in order to distinguish multiple
executions. If no id is given the id is implicitly {{default}}. And this works,
if you run the maven lifecycle phase {{verify}}, to which the check goal is
automatically bound:
{{mvn clean verify}}
This of course, executes a bit more (e.g. it compiles and runs the unit tests
as well). During the execution, the pmd check goal is executed with your
configured {{excludeFromFailureFile}}.
If you only want to run {{mvn clean pmd:check}}, then you have three
possibilities:
1. You can force a specific execution id: {{mvn clean pmd:check@default}},
which will then pick-up your configuration (note: this feature was introduced,
I guess, in some late maven 3.3.x version).
2. you can set the execution id in your pom.xml to be {{default-cli}} - this is
the execution configuration id, that is used by default, if a plugin goal is
executed directly from command line:
{noformat}
...
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<excludeFromFailureFile>${basedir}/config/pmd/pmd-exclude.properties</excludeFromFailureFile>
</configuration>
</execution>
</executions>
{noformat}
3. You can move the configuration for {{excludeFromFailureFile}} up, where you
have specified {{<verbose>true</verbose>}}.
----
However, it is *recommended for PMD* to run it after your code has been
compiled and simply use {{mvn clean verify}}. The reason is, that PMD takes
advantage of the compiled classes, when they are available in order to improve
detection of problems and also avoid false positives. The feature in PMD behind
this is called "typeresolution" and is enabled in the maven pmd plugin by
default (via the
[typeResolution|https://maven.apache.org/plugins/maven-pmd-plugin/pmd-mojo.html#typeResolution]
property).
Therefore I'm going to close this issue. Let me know, if it still doesn't work
for you.
> excludeFromFailureFile configuration does not work
> --------------------------------------------------
>
> Key: MPMD-243
> URL: https://issues.apache.org/jira/browse/MPMD-243
> Project: Maven PMD Plugin
> Issue Type: Bug
> Components: PMD
> Affects Versions: 3.2, 3.5, 3.7, 3.8
> Reporter: Benedikt Ritter
> Assignee: Andreas Dangel
>
> The excludeFromFailureFile configruation is ignored since version 3.1 of
> Maven PMD plugin. Here is my plugin configuration:
> {code}
> <plugin>
> <artifactId>maven-pmd-plugin</artifactId>
> <!-- Latest version is 3.8, all version above 3.1 ignore the excludes
> file, hence we're downgrading to 3.1 -->
> <version>3.8</version>
> <configuration>
> <verbose>true</verbose>
> </configuration>
> <executions>
> <execution>
> <goals>
> <goal>check</goal>
> </goals>
> <configuration>
>
> <excludeFromFailureFile>${basedir}/config/pmd/pmd-exclude.properties</excludeFromFailureFile>
> </configuration>
> </execution>
> </executions>
> </plugin>
> {code}
> The pmd-exclude.properties file has the following content:
> {code}
> com.example.ClassWithLotsOfStaticImports=TooManyStaticImports
> {code}
> When I execude mvn clean pmd:check, I get a violation for
> ClassWithLotsOfStaticImports. It works with 3.0 and 3.1. I've testet several
> version above 3.1.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)