Maven 1.x PMD Plugin

PMD should run on unit tests

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.7
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    2

Description

Right now the only files under "pom.build.sourceDirectory" are checked. It would be nice is source under "pom.build.unitTestSourceDirectory" could be checked as well.

Activity

Hide
Sebastian Esponda added a comment -

Right!...It would be nice. I've temporary edited plugin.jelly and duplicated the fileset section with:

<fileset dir="${pom.build.unitTestSourceDirectory}" ...
...

Regards!

Show
Sebastian Esponda added a comment - Right!...It would be nice. I've temporary edited plugin.jelly and duplicated the fileset section with: <fileset dir="${pom.build.unitTestSourceDirectory}" ... ... Regards!
Hide
Sebastian Esponda added a comment -

This CVS patch will add a fileset including the tests (pom.build.unitTestSourceDirectory), only if the properties points to a valid directory.
Created editing version 1.15.

Regards,

Show
Sebastian Esponda added a comment - This CVS patch will add a fileset including the tests (pom.build.unitTestSourceDirectory), only if the properties points to a valid directory. Created editing version 1.15. Regards,
Hide
Sebastian Esponda added a comment -

We needed PMD to analyze our tests sources, so we did some changes:

Plugin.jelly:

If ${pom.build.unitTestSourceDirectory} points to a valid directory, a second fileset is included in pmd ant task.

Plugin.jsl:

The original file always used <a href="xref/... etc > when linking line numbers to sources. This failed for tests sources.
Now, if the file path starts with ${pom.build.unitTestSourceDirectory} the link will be <a href="xref-test/... etc >

In the zip file I’m including:

New plugin.jelly
New plugin.jsl
Patch for plugin.jelly 1.15 (Previously posted, included here for convenience)
Patch for plugin.jsl 1.4

... just in case you find it useful (hope so)
I’ve just learned jsl and jelly... so this is probably with bugs... but it’s working ok in our environment

Regards,

Show
Sebastian Esponda added a comment - We needed PMD to analyze our tests sources, so we did some changes: Plugin.jelly: If ${pom.build.unitTestSourceDirectory} points to a valid directory, a second fileset is included in pmd ant task. Plugin.jsl: The original file always used <a href="xref/... etc > when linking line numbers to sources. This failed for tests sources. Now, if the file path starts with ${pom.build.unitTestSourceDirectory} the link will be <a href="xref-test/... etc > In the zip file I’m including: New plugin.jelly New plugin.jsl Patch for plugin.jelly 1.15 (Previously posted, included here for convenience) Patch for plugin.jsl 1.4 ... just in case you find it useful (hope so) I’ve just learned jsl and jelly... so this is probably with bugs... but it’s working ok in our environment Regards,
Hide
Wim Deblauwe added a comment -

Got the same problem, hopefully this makes it into the next release. Maybe we should have a property called 'maven.pmd.includetestdir' to tweak this behaviour.

You need something like this to do it:

<j:set var="addtestdir" value="${maven.pmd.includetestdir}"/>
<j:if test="${addtestdir == 'true'}">
<ant:echo>Including unit test directory: ${pom.build.unitTestSourceDirectory}</ant:echo>
<fileset dir="${pom.build.unitTestSourceDirectory}"/>
</j:if>

Show
Wim Deblauwe added a comment - Got the same problem, hopefully this makes it into the next release. Maybe we should have a property called 'maven.pmd.includetestdir' to tweak this behaviour. You need something like this to do it: <j:set var="addtestdir" value="${maven.pmd.includetestdir}"/> <j:if test="${addtestdir == 'true'}"> <ant:echo>Including unit test directory: ${pom.build.unitTestSourceDirectory}</ant:echo> <fileset dir="${pom.build.unitTestSourceDirectory}"/> </j:if>
Hide
Carlos Sanchez added a comment -

Fixed, but in a different way.

See property maven.pmd.check.tests

Show
Carlos Sanchez added a comment - Fixed, but in a different way. See property maven.pmd.check.tests

People

Vote (4)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: