![](/img/trans.png)
[英]How to skip "This project is using version xxx of android gradle plugin, which is incompatible with this version of android studio" dialog?
[英]How to find which checkstyle version gradle is using?
在我的 gradle 文件中,我有:
apply plugin: 'checkstyle'
我正在尝试创建自己的 checkstyle 规则。 出于这个原因,我在我的 gradle 文件中添加了一个依赖项。
dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:8.2'
}
我正在尝试扩展 checkstyle 的“Check”类。 但是checkstyle的版本很多,不知道gradle用的是哪一个。
如何找到 gradle 使用的 checkstyle 的确切版本号?
我现在能想到三种方式,首先是最不吸引人的:
但是推荐的方法是通过在 build.gradle 文件中指定它来明确选择Checkstyle 版本:
checkstyle { configFile file('your/checkstyle.xml'); toolVersion '8.2'; // your choice here }
这比依赖默认版本要好,因为您可以使用更新版本的 Checkstyle,并且更新 Gradle 时您的 Checkstyle 设置不会中断。
提供更好的解决方案,可以参考checkstyle源码中的配置文件示例,无需担心兼容性问题。
只需运行gradle dependencies | grep checkstyle
gradle dependencies | grep checkstyle
然后在此处获取相应的checkstyle源以参考配置示例: https : //github.com/checkstyle/checkstyle/releases
您可以通过将其写入 build.gradle 文件并重新加载 gradle 项目来检查checkstyle.toolVersion
的当前值
plugins {
id 'java'
id 'checkstyle'
}
println checkstyle.toolVersion
使用开箱即用的apply plugin: 'checkstyle'
,checkstyle 将使用v6.19 。
下载的依赖:
Download https://repo1.maven.org/maven2/com/puppycrawl/tools/checkstyle/6.19/checkstyle-6.19.pom
Download https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.5.3/antlr4-runtime-4.5.3.pom
Download https://repo1.maven.org/maven2/org/antlr/antlr4-master/4.5.3/antlr4-master-4.5.3.pom
Download https://repo1.maven.org/maven2/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3.pom
Download https://repo1.maven.org/maven2/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.pom
Download https://repo1.maven.org/maven2/org/apache/commons/commons-parent/41/commons-parent-41.pom
Download https://repo1.maven.org/maven2/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar
Download https://repo1.maven.org/maven2/com/puppycrawl/tools/checkstyle/6.19/checkstyle-6.19.jar
Download https://repo1.maven.org/maven2/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3.jar
Download https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.5.3/antlr4-runtime-4.5.3.jar
在dependencies { checkstyle 'com.puppycrawl.tools:checkstyle:8.2' }
,下载的依赖列表:
Download https://repo1.maven.org/maven2/com/puppycrawl/tools/checkstyle/8.2/checkstyle-8.2.pom
Download https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.7/antlr4-runtime-4.7.pom
Download https://repo1.maven.org/maven2/org/antlr/antlr4-master/4.7/antlr4-master-4.7.pom
Download https://repo1.maven.org/maven2/commons-cli/commons-cli/1.4/commons-cli-1.4.pom
Download https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.8.0-4/Saxon-HE-9.8.0-4.pom
Download https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.7/antlr4-runtime-4.7.jar
Download https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.8.0-4/Saxon-HE-9.8.0-4.jar
Download https://repo1.maven.org/maven2/commons-cli/commons-cli/1.4/commons-cli-1.4.jar
Download https://repo1.maven.org/maven2/com/puppycrawl/tools/checkstyle/8.2/checkstyle-8.2.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.