我试图从maven迁移到gradle,检查样式出现了一个奇怪的错误。
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:0.5.3.RELEASE'
}
}
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'checkstyle'
jar {
version = '0.1.0-SNAPSHOT'
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencyManagement {
imports {
mavenBom 'io.spring.platform:platform-bom:1.1.3.RELEASE'
}
}
dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:6.10.1'
compile('org.springframework.data:spring-data-commons')
testCompile('junit:junit')
testCompile('org.mockito:mockito-core')
testCompile('nl.jqno.equalsverifier:equalsverifier:1.7.5')
}
test {
maxParallelForks = 4
}这是我要犯的错误
gradle build slave-vi
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:checkstyleMain FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':checkstyleMain'.
> Unable to create a Checker: unable to read /home/xenoterracide/IdeaProjects/entity-api/config/checkstyle/checkstyle.xml - unable to parse configuration stream - Property ${checkstyle.cache.file} has not been set
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.688 secs如何让gradle使用最新版本的checkstyle?值得注意的是,我的checkstyle.xml确实使用了maven校验样式6.10.1和6.8。
发布于 2015-09-24 03:22:35
我在配置中找到了这个
<property name="cacheFile" value="${checkstyle.cache.file}"/>我不记得添加了它,也许它是sun配置文件的一部分,只是碰巧被maven插件所填充。
发布于 2016-01-06 09:52:15
这里的问题是,您使用的是校验风格的插件,但您没有为它指定任何配置。在这里,您应该添加
checkstyle {
ignoreFailures = true
configFile = file("/home/jenkins/scripts/checks.xml")
}并且您应该在上面提到的位置有您的校验样式文件(您可以更改为任何您想要的)。
下面是带有校验样式、PMD、findbug、jacoco等的示例gradle文件。http://www.scmtechblog.net/2016/01/sample-gradle-file.html
您可以将这些信息添加到您的build.gradle中以利用它。
https://stackoverflow.com/questions/32752639
复制相似问题