我正在做从Gradle 1.6迁移到2.1的POC工作(基本上是为了解决此问题:Gradle build / test failed - kryo.KryoException: Buffer overflow)。
Gradle构建可与Gradle 1.6一起成功运行
使用Gradle 2.1,当我运行“gradle clean build”时,我收到以下错误消息。
FAILURE: Build failed with an exception.
* Where:
Initialization script '/production/gradle-2.1/init.d/extra1.common-thids.gradle' line: 19
* What went wrong:
Could not find property 'Compile' on root project 'Infrastructure'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
和
:findbugsMain FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':findbugsMain'.
> The version of FindBugs (3.0.0) inferred from FindBugs classpath is too high to work with currently used Java version (1.6). Please use lower version of FindBugs or use newer version of Java. Inspected FindBugs classpath: [findbugs-3.0.0.jar, bcel-findbugs-6.0.jar, annotations-3.0.0.jar, jFormatString-3.0.0.jar, dom4j-1.6.1.jar, jaxen-1.1.6.jar, asm-debug-all-5.0.2.jar, commons-lang-2.6.jar, xml-apis-1.0.b2.jar]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
全局级别的init.d / extra1 ...常见的gradle文件行是:我使用了相同的init.d文件(用于存储库设置和其他与Gradle 1.6一起使用的全局设置,该设置已应用了findbugs,pmd,java等插件等)。我将debug设置为true,以便jacoco可以产生代码覆盖率。知道吗,如何使用Gradle 2.1将选项debug设置为true?
对于findbugs问题,我不想将JAVA / JDK版本从1.6升级到1.7.0 40(当前,因为此核心项目的 Artifact 已被仍在JAVA JDK 1.6上的其他项目占用)。谢谢。
18
19 tasks.withType(Compile) {
20 options.debug = true
21 options.compilerArgs = ["-g"]
22 }
23
最佳答案
Compile
重命名为JavaCompile
。可以通过findbugs { toolVersion = "x.y.z" }
配置要使用的FindBugs版本。
关于debugging - Gradle-Gradle 2.1的编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26790831/