SonarQube 是否支持 Java 8?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22497165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does SonarQube support Java 8 yet?
提问by xyzlast
With Java 8, executing gradle sonarRunner
shows this error message.
(sonarQube version : 4.2.1)
使用 Java 8,执行会gradle sonarRunner
显示此错误消息。(sonarQube 版本: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]
```
Does SonarQube not support Java 8 yet? I would like to know when support is available.
SonarQube 不支持 Java 8 吗?我想知道什么时候可以提供支持。
Thank you.
谢谢你。
采纳答案by Matthias Braun
SonarQube supportsJava 8 since end of March 2014 (with some hickupsat first, which were fixed in version 2.2 of its Java plugin).
SonarQube自 2014 年 3 月下旬开始支持Java 8(起初有一些问题,在其 Java 插件的 2.2 版中已修复)。
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.
我不得不卸载 Sonar 更新中心中的 PMD 和 Checkstyle 插件,因为它们还没有为 Java 8 做好准备。无论如何,Sonar 自己的规则引擎 Squid 应该使这些插件变得多余。
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.
如果您使用 Gradle 1.11 调用 Sonar 并希望 Jacoco 计算代码覆盖率,则必须指定最新的 Jacoco 版本才能分析 Java 8 字节码。
Here's my script that does that when called with gradle test jacocoTestReport sonarRunner
:
这是我的脚本,它在调用时执行此操作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
}
}
回答by David RACODON - QA Consultant
It will be supported very soon. See http://jira.codehaus.org/browse/SONARJAVA-386.
很快就会得到支持。请参阅http://jira.codehaus.org/browse/SONARJAVA-386。
回答by tischda
There are 2 sides to your question:
你的问题有两个方面:
- The sonarRunner (client)
- The SonarQube application (server)
- sonarRunner(客户端)
- SonarQube 应用程序(服务器)
The error you receive comes from the Java Ecosystemplugins that are downloaded to the client and rely on an old version of ASM (3.2). AFAIK Java 8 support starts with version 5.0. You'll have the same issue with Findbugs and Jacoco. See also this discussion.
您收到的错误来自下载到客户端并依赖于旧版本 ASM (3.2)的Java 生态系统插件。AFAIK Java 8 支持从 5.0 版开始。Findbugs 和 Jacoco 也会遇到同样的问题。另请参阅此讨论。
Concerning the SonarQube server, you can start it, but it crashes when you select "Configure widgets", so I would say no, it does not support Java 8 yet.
关于 SonarQube 服务器,您可以启动它,但是当您选择“配置小部件”时它会崩溃,所以我会说不,它还不支持 Java 8。