Java8项目的SonarQube提供了jacoco-Exception

Rop*_*Rop 15 java java-8 jacoco sonarqube

我刚刚下载了最新版本的SonarQube 4.3,然后尝试使用以下命令构建一个java-8项目:

  mvn clean install
  mvn sonar:sonar
Run Code Online (Sandbox Code Playgroud)

这给了我下面的例外.

谷歌搜索,我得到的印象这是一个应该修复的早期问题......?

http://sonarqube.15.x6.nabble.com/Sonar-analyze-Java-1-8-project-Failure-td5023663.html

http://jira.codehaus.org/browse/SONARJAVA-482

SonarQube 4.3是否支持java-8?

或者任何线索,有什么问题?

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
        at org.jacoco.agent.rt.internal_6effb9e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
        at org.jacoco.agent.rt.internal_6effb9e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:99)
        at org.jacoco.agent.rt.internal_6effb9e.PreMain.createRuntime(PreMain.java:55)
        at org.jacoco.agent.rt.internal_6effb9e.PreMain.premain(PreMain.java:47)
        ... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
        at java.lang.Class.getField(Class.java:1690)
        at org.jacoco.agent.rt.internal_6effb9e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:136)
        ... 9 more
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main"
Run Code Online (Sandbox Code Playgroud)

Rop*_*Rop 13

我从SonarQube邮件列表中得到了缺失的信息......总结一下:

要在SonarQube-4.3上运行Java8 maven-build:

  • 安装sonarqube-4.3,然后启动服务器.

  • 登录web-gui =>设置=>更新中心=>插件更新=> Java =>点击"升级到2.2.1"

等一下左右升级完成...然后关机+重新启动sonarqube.返回升级中心并验证您是否有插件:Java 2.2.1

参考:http://docs.codehaus.org/display/SONAR/JaCoCo+Plugin

而已.


Mar*_*nes 6

在这里使用 java 11 我遇到了这个问题,我修复了在我的 gradle 属性中添加它的问题:

jacoco {
  toolVersion = "0.8.4"
}
Run Code Online (Sandbox Code Playgroud)