diff --git a/build.gradle b/build.gradle index 3aae64cb00..ebf40b22fb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. apply from: "config.gradle" apply from: "javadoc.gradle" + buildscript { apply from: rootProject.file('gradle/ext.gradle') repositories { @@ -50,6 +51,7 @@ buildscript { } allprojects { + apply from: rootProject.file('codequality/pmd.gradle') repositories { mavenLocal() maven { url 'http://nexus.zhidaoauto.com/repository/maven-releases/' } @@ -70,7 +72,6 @@ allprojects { } google() } - } task clean(type: Delete) { diff --git a/codequality/custom-pmd-ruleset.xml b/codequality/custom-pmd-ruleset.xml new file mode 100644 index 0000000000..b39e789ff2 --- /dev/null +++ b/codequality/custom-pmd-ruleset.xml @@ -0,0 +1,41 @@ + + + + This ruleset checks my code for bad stuff + + + + + .*/R.java + .*/gen/.* + .*Dagger*.* + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/codequality/pmd.gradle b/codequality/pmd.gradle index f185527189..3a7aa35a78 100644 --- a/codequality/pmd.gradle +++ b/codequality/pmd.gradle @@ -1 +1,25 @@ -//apply plugin:"pmd" +apply plugin: "pmd" + +def pmdConfigPath = rootProject.file("codequality").path + +task pmd(type:Pmd){ + //忽略失败,如果设置为true,检测出bug会停止task + ignoreFailures = false + consoleOutput = true + //filter路径 + ruleSetFiles = files("${pmdConfigPath}/custom-pmd-ruleset.xml") // todo 新增rules + ruleSets = [] + //检测资源路径 + source 'src/main/java','src/jinlvvan/java','src/driverm1/java' + //排除项 + exclude '**/gen/**' + + reports { + xml.getRequired().set(false) + html.getRequired().set(true) + //结果输出到项目根目录下的 build/reports/pmd 文件夹中,只需要html格式的结果文档 + def destination = new File(new File("${project.rootProject.buildDir.path}/reports/pmd"), "${project.name}-pmd.html") + html.destination(destination) + } + +} \ No newline at end of file