Menu

#1295 PMDTask ClassNotFoundException with gradle

PMD-5.4.0
obsolete
None
PMD
2-Critical
Bug
5.2.2
2015-05-18
2014-12-15
No

Hello,

I am getting a ClassNotFoundException for net.sourceforge.pmd.ant.PMDTask when trying to create an ant task in gradle for the following line:

ant.taskdef(name: 'pmd', classname: 'net.sourceforge.pmd.ant.PMDTask')

This doesn't happen on 5.1.2

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-12-18
    • status: open --> more-info-needed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-Next
     
  • Andreas Dangel

    Andreas Dangel - 2014-12-18

    Please note, that with PMD 5.2.0 pmd has been modularized, so you'll need to add net.sourceforge.pmd:pmd-core as well as any language (e.g. net.sourceforge.pmd:pmd-java) in your dependencies list.

    Does the documentation here http://www.gradle.org/docs/current/userguide/ant.html#useExternalAntTaskWithConfig describe what you want to do?

    Then it would be for pmd >= 5.2 the following example:

    configurations {
        pmd
    }
    
    dependencies {
        pmd(
            'net.sourceforge.pmd:pmd-core:5.2.2',
            'net.sourceforge.pmd:pmd-java:5.2.2'
        )
    }
    
    task check << {
        ant.taskdef(name: 'pmd',
                    classname: 'net.sourceforge.pmd.ant.PMDTask',
                    classpath: configurations.pmd.asPath)
        ant.pmd(shortFilenames: 'true',
                failonruleviolation: 'true',
                rulesetfiles: file('pmd-rules.xml').toURI().toString()) {
            formatter(type: 'text', toConsole: 'true')
            fileset(dir: 'src')
        }
    }
    

    Does this work for you?

     
  • Andreas Dangel

    Andreas Dangel - 2014-12-21
    • Milestone: PMD-5.2.3 --> PMD-Next
     
  • msteiger

    msteiger - 2015-03-28

    I think that this is a gradle issue, not a PMD one. It should be fixed with Gradle 2.4, which will probably contains this commit here:

    https://github.com/gradle/gradle/commit/b07541e985b17d07f7141b19fd64a10e33c4a0bd

     
  • Andreas Dangel

    Andreas Dangel - 2015-04-01
    • Milestone: PMD-5.3.0 --> PMD-5.3.1
     
  • Andreas Dangel

    Andreas Dangel - 2015-04-20
    • Milestone: PMD-5.3.1 --> PMD-5.4.0
     
  • Andreas Dangel

    Andreas Dangel - 2015-05-18

    This seems to have been fixed with Gradle 2.4.

     
  • Andreas Dangel

    Andreas Dangel - 2015-05-18
    • summary: PMDTask ClassNotFoundException --> PMDTask ClassNotFoundException with gradle
    • status: more-info-needed --> obsolete
    • Ruleset / Rule: -->
     

Log in to post a comment.

MongoDB Logo MongoDB