Hello,
Yes, I've tried configuring multiple executions, but we are still unable to
configure PMD and CPD differently, specifically with regards to the
<includeTests> configuration.
I've logged an issue, but there has been no response:
https://jira.codehaus.org/browse/MPMD-132
With multiple executions configured something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>compliance-pmd</id>
<phase>verify</phase>
<goals>
<goal>check</goal> <!-- invokes 'pmd' goal -->
</goals>
<configuration>
<includeTests>true</includeTests>
</configuration>
</execution>
<execution>
<id>compliance-cpd</id>
<phase>verify</phase>
<goals>
<goal>cpd-check</goal> <!-- invokes 'cpd' goal -->
</goals>
<configuration>
<includeTests>false</includeTests>
</configuration>
</execution>
</executions>
</plugin>
When the check goal invokes the pmd goal, and when the cpd-check goal
invokes cpd, the <includeTests> configuration is not picked up by the pmd
and cpd goals, so the default (or whatever is in a <configuration> block
outside of the executions) is what takes effect. This means I can't
configure PMD and CPD to do different things.
Running the above POM with "mvn -X verify" shows:
[DEBUG] --- init fork of com.example:module:1.0-SNAPSHOT for
org.apache.maven.plugins:maven-pmd-plugin:2.5:check (compliance-pmd) ---
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): []
[DEBUG]
-----------------------------------------------------------------------
[DEBUG] Goal: org.apache.maven.plugins:maven-pmd-plugin:2.5:pmd
(pmd)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<aggregate default-value="false">${aggregate}</aggregate>
<compileSourceRoots>${project.compileSourceRoots}</compileSourceRoots>
<format default-value="xml">${format}</format>
<includeTests default-value="false"/>
...
Even though I have "<includeTests>true</includeTests>" in the execution
configuration for the check goal, it's not picked up when the check goal
invokes the pmd goal.
On Tue, Aug 9, 2011 at 11:32 AM, Baptiste MATHUS <[email protected]> wrote:
> I cannot test it right now, but have you tried setting two different
> executions for the plugin.
> By the way check seems to only concern pmd, and "cpd-check" cpd.
>
>
> http://maven.apache.org/plugins/maven-pmd-plugin/examples/violationChecking.html
>
> My 2 cents.
>
> 2011/8/9 Derek Lewis <[email protected]>
>
> > Hello,
> >
> > I've been working with Oskar, trying to figure out how to go about
> > configuring PMD and CPD at the same time, but with different
> > configurations.
> >
> > After investigating things further (via the internals of the
> > maven-pmd-plugin) it looks like the check goal invokes the pmd goal
> through
> > some built in Maven functionality that allows goals to invoke other
> goals.
> > However, I don't see any way to configure the goal that's being invoked,
> > for
> > that particular execution. ie. when check invokes pmd, I can configure
> the
> > check goal, but not the pmd goal, unless I put the configuration outside
> > the
> > execution, which causes it to affect other executions.
> >
> > Is there something we're missing about being able to configure these
> > chained
> > goals?
> >
> > Thanks,
> > Derek
> >
> > On Mon, Aug 8, 2011 at 9:23 AM, Oskar Separovic <
> > [email protected]> wrote:
> >
> > > 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?
> > >
> > > [http://elasticpath.com/images/ep.gif]
> > > Oskar Separovic, Release Engineer
> > > Phone: 604.408.8078 ext. 744
> > > Email: [email protected]<mailto:
> > > [email protected]>
> > >
> > > Elastic Path Software, Inc.
> > > Web elasticpath.com <http://www.elasticpath.com/> | Blog
> getelastic.com<
> > > http://www.getelastic.com/> | Twitter twitter.com/elasticpath <
> > > http://www.twitter.com/elasticpath>
> > > Careers elasticpath.com/jobs<http://www.elasticpath.com/jobs> |
> > Community
> > > grep.elasticpath.com <http://grep.elasticpath.com/>
> > >
> > > Confidentiality Notice: This message is intended only for the use of
> the
> > > designated addressee(s), and may contain information that is
> privileged,
> > > confidential and exempt from disclosure. Any unauthorized viewing,
> > > disclosure, copying, distribution or use of information contained in
> this
> > > e-mail is prohibited and may be unlawful. If you received this e-mail
> in
> > > error, please reply to the sender immediately to inform us you are not
> > the
> > > intended recipient and delete the email from your computer system.
> > >
> > >
> > >
> > >
> >
>
>
>
> --
> Baptiste <Batmat> MATHUS - http://batmat.net
> Sauvez un arbre,
> Mangez un castor !
>