rb512
rb512

Reputation: 6958

pmd gradle basic config

I want to add a PMD task to my gradle build, that would give me a pmd report in csv format. I found the pmd gradle docs too subtle and couldn't figure out how to achieve this. Can someone post a simple example?

Upvotes: 4

Views: 3259

Answers (2)

rb512
rb512

Reputation: 6958

Figured out:

task pmd << {
    println 'Running PMD static code analysis'
    ant {
        taskdef(name:'pmd', classname:'net.sourceforge.pmd.ant.PMDTask', classpath: configurations.pmdConf.asPath)

        pmd(shortFilenames:'true', failonruleviolation:'true', rulesetfiles:'conf/pmd-rules.xml') {
            formatter(type:'csv', tofile:'myreport.csv', toConsole:'true')
            fileset(dir: "src/main/java") {
                include(name: '**/*.java')
            }
            fileset(dir: "src/test/java") {
                include(name: '**/*.java')
            }        
        }
    }
}

Upvotes: 1

ajoberstar
ajoberstar

Reputation: 2585

The Gradle PMD plugin, I believe will only create XML and HTML reports. You can look at the DSL reference for more information on the PMD task.

Upvotes: 0

Related Questions