PMD、checkstyle和findbugs android设置
如何使用最新版本的gradle为Android项目设置PMD、Findbugs和Checkstyle静态代码分析工具?我试过几种方法,但都没成功PMD、checkstyle和findbugs android设置,android,gradle,checkstyle,findbugs,pmd,Android,Gradle,Checkstyle,Findbugs,Pmd,如何使用最新版本的gradle为Android项目设置PMD、Findbugs和Checkstyle静态代码分析工具?我试过几种方法,但都没成功 谢谢检查样式/PMD 有一个很好的插件可以用于checkstyle和pmd。加上 buildscript { repositories { // ... } dependencies { // ... classpath 'com.android.tools.build:gradl
谢谢检查样式/PMD 有一个很好的插件可以用于checkstyle和pmd。加上
buildscript {
repositories {
// ...
}
dependencies {
// ...
classpath 'com.android.tools.build:gradle:1.2.3'
// Enables checkStyle and pmd gradle support for android modules
classpath 'com.noveogroup.android:check:1.1.2'
}
}
到您的global gradle.build,并在您的模块中使用它,如下所示:
apply plugin: 'com.noveogroup.android.check'
check {
abortOnError false
checkstyle {
config "$rootProject.rootDir/path/to/your/checkstyle.xml"
}
pmd {
config "$rootProject.rootDir/path/tp/your/pmd-ruleset.xml"
}
}
<FindBugsFilter>
<Match>
<Class name="~.*R\$.*"/>
</Match>
<Match>
<Class name="~.*Manifest\$.*"/>
</Match>
<Match>
<Class name="~.*_"/>
</Match>
</FindBugsFilter>
或以下任何一种配置:
// configuration is optional
check {
// skip source code checking or not, false by default
skip true/false
// fails build if code style violation is found, false by default
abortOnError true/false
checkstyle {
// skip Checkstyle, false by deafult
skip true/false
// fails build if Checkstyle rule violation is found, false by default
abortOnError true/false
// configuration file
config project.file('path/to/checkstyle.xml')
// configuration resource
// see http://gradle.org/docs/2.2/release-notes#sharing-configuration-files-across-builds
config resources.text.fromFile(someTask)
// configuration path
config 'path/to/checkstyle.xml'
// predefined configurations: easy and hard
config easy()
config hard()
// plugin find configuration file in project.file('config/checkstyle.xml') by default
// if there are no configuration file, easy() configuration will be used
}
pmd {
// the same configuration as for Checkstyle
// plugin find configuration file in project.file('config/pmd.xml') by default
// if there are no configuration file, easy() configuration will be used
}
}
你可以找到插件的主页和源代码
Findbugs
//更新//
noveogroup的最新插件(1.2.3)现在也支持findbugs。因此,您可以像checkstyle或pmd一样对其进行自定义:
// configuration of FindBugs checker
findbugs {
// the same configuration as for Checkstyle
// by default plugin finds configuration file in <rootProject>/config/findbugs.xml,
// after that in <project>/config/findbugs.xml and if there are no configuration
// file, easy() configuration will be used.
}
My exclude.xml如下所示:
apply plugin: 'com.noveogroup.android.check'
check {
abortOnError false
checkstyle {
config "$rootProject.rootDir/path/to/your/checkstyle.xml"
}
pmd {
config "$rootProject.rootDir/path/tp/your/pmd-ruleset.xml"
}
}
<FindBugsFilter>
<Match>
<Class name="~.*R\$.*"/>
</Match>
<Match>
<Class name="~.*Manifest\$.*"/>
</Match>
<Match>
<Class name="~.*_"/>
</Match>
</FindBugsFilter>
你找到解决办法了吗?这是我试用的可能的副本