问题描述
使用Java 8,执行 gradle sonarRunner
会显示此错误消息。
(sonarQube版本:4.2.1)
With Java 8, executing gradle sonarRunner
shows this error message.(sonarQube version : 4.2.1)
java.lang.ArrayIndexOutOfBoundsException: 26721
at org.objectweb.asm.ClassReader.readClass(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
at org.objectweb.asm.ClassReader.accept(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
at org.objectweb.asm.ClassReader.accept(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
at org.sonar.java.bytecode.asm.AsmClassProviderImpl.decoracteAsmClassFromBytecode(AsmClassProviderImpl.java:76) [java-squid-2.0.jar:na]
at org.sonar.java.bytecode.asm.AsmClassProviderImpl.getClass(AsmClassProviderImpl.java:55) [java-squid-2.0.jar:na]
at org.sonar.java.bytecode.asm.AsmClassVisitor.visit(AsmClassVisitor.java:52) [java-squid-2.0.jar:na]
at org.objectweb.asm.ClassReader.accept(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
at org.objectweb.asm.ClassReader.accept(Unknown Source) [asm-all-3.2.jar:5.0_BETA]
```
是否S onarQube不支持Java 8了吗?我想知道什么时候有支持。
Does SonarQube not support Java 8 yet? I would like to know when support is available.
谢谢。
推荐答案
SonarQube Java 8 2014年3月底(有一些 at at首先,它已在其Java插件的2.2版本中得到修复。)
SonarQube supports Java 8 since end of March 2014 (with some hickups at first, which were fixed in version 2.2 of its Java plugin).
我必须卸载Sonar更新中心的PMD和Checkstyle插件,因为它们还没有为Java 8做好准备Sonar自己的规则引擎Squid应该让这些插件多余。
I had to uninstall the PMD and Checkstyle plugins in Sonar's update center as those are not ready for Java 8. Sonar's own rule engine Squid should make those plugins redundant anyway.
如果你使用Gradle 1.11来调用Sonar并且想要Jacoco计算代码覆盖率,你必须指定最新的Jacoco版本才能分析Java 8字节码。
If you are using Gradle 1.11 to call Sonar and want Jacoco to calculate code coverage, you'll have to specify the latest Jacoco version in order to analyze Java 8 bytecode.
这是我用<$调用时执行该操作的脚本c $ c> gradle test jacocoTestReport sonarRunner :
/** This script is responsible for unit testing and static analysis of the project source code*/
apply plugin: "jacoco"
apply plugin: "sonar-runner"
// Location of the XML unit test and code coverage reports
def testResultsDir = "$buildDir/test-results/" // Use double quotes. Otherwise the $ won't work
jacoco{
// Gradle 1.11 ships with a Jacoco version that doesn't support Java 8
toolVersion = "0.7.0.201403182114"
}
// Call "gradle test jacocoTestReport" to produce a code coverage report at "build/reports/jacoco/test/html/index.html"
test {
jacoco {
def coverageReport = new File(testResultsDir, "jacocoTest.exec")
destinationFile = file(coverageReport)
}
}
// Let SonarQube analyze the project
sonarRunner {
sonarProperties {
property "sonar.projectKey", projectId
property "sonar.projectName", projectName
property "sonar.junit.reportsPath", testResultsDir
// Address of SonarQube server
property "sonar.host.url", "http://localhost:9000"
// SonarQube stores the test results in this database
property "sonar.jdbc.url", "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true"
property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
property "sonar.jdbc.username", "root"
property "sonar.jdbc.password", sonarDBpassword
}
}
这篇关于SonarQube是否支持Java 8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!