pmd gradle基本配置

时间:2012-08-07 17:50:36

标签: gradle pmd

我想在我的gradle构建中添加一个PMD任务,这将给我一个csv格式的pmd报告。我发现pmd gradle文档过于微妙,无法弄清楚如何实现这一目标。有人可以发一个简单的例子吗?

2 个答案:

答案 0 :(得分:1)

想通了:

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')
            }        
        }
    }
}

答案 1 :(得分:0)

Gradle PMD plugin,我相信只会创建XML和HTML报告。您可以查看DSL参考,了解有关PMD task

的更多信息