You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Oskar S <os...@gmail.com> on 2011/08/05 22:14:26 UTC

Problem configuring PMD and CPD differently

Hello,

We're using the PMD plugin to run both PMD and CPD on our codebase, however,
we've come across
a problem that has led us to disable CPD as a workaround. Specifically, we
want to run PMD on all our
code, but run CPD on only production code. The <includeTests> configuration
tag appears to allow us to do this,
however, when running both PMD and CPD, there doesn't seem to be any way to
configure them differently.

The problem seems to be that when you add configuration tags within an
execution, the tags are specific to the goal specified,
and have no function if the goal doesn't support them, even if that goal
invokes
another goal that does support those configuration tags.

For the PMD plugin this means that when the check/cpd-check goals invoke the
pmd/cpd goals, the pmd/cpd goals cannot be configured within the execution.

If another execution configures the pmd/cpd goals, then the goals will
run twice, once with the specified configuration and once with the default
configuration.

The only way to configure the pmd/cpd goals when invoked from the
check/cpd-check goals
is to add them to a configuration outside the execution.

The problem with this is that the configuration outside the executions
applies to
both the pmd and cpd goals, so the pmd and cpd goals cannot be configured
differently
(for example running pmd on tests but not cpd).

The best suggestion we have come up with to fix this is for the
check/cpd-check goals
to support all the configuration tags of the pmd and cpd goals respectively,
and somehow pass them
to the pmd and cpd goals when the check goals invoke them.

For example configuring the check goal like this currently does not work,
but ideally it should
pass the rulesets configuration to the pmd goal that is invoked:

<execution>
    <id>compliance-pmd</id>
    <phase>verify</phase>
    <goals>
      <goal>check</goal>
    </goals>
    <configuration>
      <rulesets>
        <ruleset>rules/pmd-rules.xml</ruleset>
      </rulesets>
    </configuration>
</execution>

Does anyone have comments on the feasibility of implementing such a
solution?

Re: Problem configuring PMD and CPD differently

Posted by Baptiste MATHUS <ml...@batmat.net>.
Hi,

Please post on the users list.
This one is for developing Maven core.

Cheers
Le 5 août 2011 22:14, "Oskar S" <os...@gmail.com> a écrit :
> Hello,
>
> We're using the PMD plugin to run both PMD and CPD on our codebase,
however,
> we've come across
> a problem that has led us to disable CPD as a workaround. Specifically, we
> want to run PMD on all our
> code, but run CPD on only production code. The <includeTests>
configuration
> tag appears to allow us to do this,
> however, when running both PMD and CPD, there doesn't seem to be any way
to
> configure them differently.
>
> The problem seems to be that when you add configuration tags within an
> execution, the tags are specific to the goal specified,
> and have no function if the goal doesn't support them, even if that goal
> invokes
> another goal that does support those configuration tags.
>
> For the PMD plugin this means that when the check/cpd-check goals invoke
the
> pmd/cpd goals, the pmd/cpd goals cannot be configured within the
execution.
>
> If another execution configures the pmd/cpd goals, then the goals will
> run twice, once with the specified configuration and once with the default
> configuration.
>
> The only way to configure the pmd/cpd goals when invoked from the
> check/cpd-check goals
> is to add them to a configuration outside the execution.
>
> The problem with this is that the configuration outside the executions
> applies to
> both the pmd and cpd goals, so the pmd and cpd goals cannot be configured
> differently
> (for example running pmd on tests but not cpd).
>
> The best suggestion we have come up with to fix this is for the
> check/cpd-check goals
> to support all the configuration tags of the pmd and cpd goals
respectively,
> and somehow pass them
> to the pmd and cpd goals when the check goals invoke them.
>
> For example configuring the check goal like this currently does not work,
> but ideally it should
> pass the rulesets configuration to the pmd goal that is invoked:
>
> <execution>
> <id>compliance-pmd</id>
> <phase>verify</phase>
> <goals>
> <goal>check</goal>
> </goals>
> <configuration>
> <rulesets>
> <ruleset>rules/pmd-rules.xml</ruleset>
> </rulesets>
> </configuration>
> </execution>
>
> Does anyone have comments on the feasibility of implementing such a
> solution?