- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含多个库的 android 项目。我想对所有源代码运行一个 checkstyle 任务。项目结构:
app (com.android.application),
lib1 (com.android.library),
lib2 (com.android.library),
...
我遵循了这个配置教程:
https://github.com/Piasy/AndroidCodeQualityConfig
项目的build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
apply from: "$rootProject.projectDir/quality.gradle"
afterEvaluate {
check.dependsOn 'checkstyle'
}
}
质量.gradle:
apply plugin: 'checkstyle'
checkstyle {
toolVersion '7.4'
configFile file("${project.rootDir}/checkstyle/checkstyle.xml")
configProperties.checkstyleSuppressionFilterPath = file(
"${project.rootDir}/checkstyle/suppressions.xml")
.absolutePath
}
task checkstyle(type: Checkstyle, group: 'verification') {
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/test/**'
exclude '**/androidTest/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
classpath = files()
}
如果我对根项目运行 gradle 检查,它只在 :app 模块上运行,而不是整个项目。
我错过了什么?谢谢。
最佳答案
这可能不是您正在寻找的答案,但我的解决方案是添加
apply from: rootProject.file("gradle/quality.gradle")
到我想运行 checkstyle 的每个模块的 build.gradle。在我的例子中,有一个或两个模块我不想让它运行。
这是我的 quality.gradle 文件
apply plugin: "checkstyle"
checkstyle {
configFile rootProject.file('checkstyle.xml')
ignoreFailures false
showViolations true
toolVersion = "8.15"
}
/** Checkstyle task for new files (not in exclude list). Fail build if a check fails **/
task checkstyle(type: Checkstyle) {
configFile rootProject.file('checkstyle/checkstyle.xml')
//fail early
ignoreFailures false
showViolations true
source 'src'
include '**/*.java'
exclude rootProject.file('checkstyle/checkstyle-exclude-list.txt') as String[]
classpath = files()
}
/** Checkstyle task for legacy files. Don't fail build on errors **/
task checkstyleLegacy(type: Checkstyle) {
configFile rootProject.file('checkstyle.xml')
ignoreFailures true
showViolations true
source 'src'
include '**/*.java'
exclude '**/gen/**'
classpath = files()
}
afterEvaluate {
preBuild.dependsOn 'checkstyle'
}
关于android - 在所有模块上运行 android checkstyle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51840917/
发现一个类似的问题,关于 QAPlug-FindBugs 和 FindBugs-IDEA 之间的区别,但不是关于 CheckStyle... 我认为(根据以前的经验)这些插件的一个区别是 QAPlug
试图弄清楚我是否做错了什么,或者这是否是 maven checkstyle 插件中的错误。如果我执行 mvn checkstyle:check 我会得到这个: jonathanfisher@odin
我想确保我的代码不超过 5 级缩进,如下所示: class Foo { // 0 void bar() { // 1 if () { // 2 if (
FileTabCharacter检查似乎对我不起作用。下面是我的配置: .. .. .. .. .. .. 我有 XML 文件 - pom.xml和 checksty
有没有办法设置 checkstyle 来防止方法体中的前导、多个或尾随空行: 例如 private void a() { - int a = 1; doStuff(a); - - doMoreStuf
有没有办法设置 checkstyle 来防止方法体中的前导、多个或尾随空行: 例如 private void a() { - int a = 1; doStuff(a); - - doMoreStuf
我是 CheckStyle 等 Java 静态代码分析工具的新手。我下载了 Checkstyle 包并看到了 2 组检查: checkstyle_checks.xml sun_checks.xml。
我想使用//@checkstyle:off 和//@checkstyle:on 来免除代码的某些部分被 checkstyle 检查,但它仍然在提示。 public void invoke() {
我正在尝试将 import-control 添加到我们的 checkstyle 中,使 import-control 文件存在于制作 checstyle.xml 文件的项目中,而不是我们稍后构建的项目
我跑了mvn checkstyle:checkstyle ,但它没有使用我的自定义 checkstyle XML 文件。 请告诉我如何使用我自己的 checkstyle 文件而不是默认/现在配置的文件
执行命令mvn checkstyle:checkstyle时出现以下错误: An error has occurred in Checkstyle report generation. ... Cau
在我正在处理的一个项目中,我们有很多自定义 Checkstyle 检查。例如,我们使用 RegexpSingleline 模块排除所有类型的东西。我们的检查样式规则如下所示:
我正在使用 checkstyle获取有关我的源代码的报告。这个问题是关于MagicNumberCheck . 我正在使用 Date/(org.joda.)DateTime在我的源代码中是这样的: Da
我通过命令行上的 mvn 构建我的项目。 每当发生 checkStyle 错误时,我都会看到这种类型的输出: [ERROR] Failed to execute goal org.apache.mav
我有一个使用 Tycho 构建的 Eclipse 插件代码库。它使用在依赖 Artifact 中定义的父 POM,该 Artifact 指定 Checkstyle 配置的名称。 我还使用 checks
我是使用 Jenkins 的新手,我最近用它构建了一个项目并安装了“Checkstyle”插件并收到了一份报告。 我想知道如何配置“Checkstyle”以忽略空格或其他可能出现的标准? 谢谢! 最佳
我过去使用过检查样式,记得使用快捷键来应用检查样式修复(节省大量点击)。我不记得我是否为它设置了快捷方式,或者它是否已经附带了一个。 我的问题分为两部分:1)有没有一种简单的方法来检查是否有“Appl
我正在使用一个基本的 maven 项目,其中在 pom.xml 中只定义了以下内容: 依赖 javaee-api 依赖 junit 插件 maven-compile-plugin 插件 maven-w
我试图让 maven-checkstyle-plugin 对我们所有的项目使用相同的配置文件。 我尝试了几种方法,但没有一种是有效的。 唯一似乎有效的是当我将配置文件放在我的 maven 项目的根目录
我在 maven 构建中添加了 checkstyle 但由于某种原因它只检查 src/main 文件夹并忽略 src/test 文件夹,这是我的项目结构: Proj - Module A -
我是一名优秀的程序员,十分优秀!