API与SonarQube 5.6和具有Findbugs 3.3或Cobertura 1.6.3的Java Analyzer 4.0不兼容 [英] API incompatibility with SonarQube 5.6 and Java Analyzer 4.0 with Findbugs 3.3 or Cobertura 1.6.3
问题描述
将 Java插件从版本3.14
更新为4.0
后,SonarQube 5.6
对我的项目进行了分析.
The analyzes of my projects are failing with SonarQube 5.6
, after updating the Java Plugin from version 3.14
to 4.0
.
在我的SonarQube实例中,除其他插件外,我目前拥有需要Java插件的Findbugs插件(版本3.3
)和Cobertura插件(1.6.3
).
In my SonarQube instance, among other plugins, I currently have the Findbugs plugin (version 3.3
) and the Cobertura plugin (1.6.3
) which require the Java plugin.
查看日志,我收到以下消息:
Looking at the log, I get the following message:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.1-build231:sonar (default-cli)
on project MyProject: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.1-build231:sonar failed:
An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.1-build231:sonar:
java.lang.NoSuchMethodError:
org.sonar.plugins.java.api.JavaResourceLocator.findResourceByClassName(Ljava/lang/String;)Lorg/sonar/api/resources/Resource;
...
Caused by: java.lang.NoSuchMethodError: org.sonar.plugins.java.api.JavaResourceLocator.findResourceByClassName(Ljava/lang/String;)Lorg/sonar/api/resources/Resource;
at org.sonar.plugins.findbugs.FindbugsSensor.analyse(FindbugsSensor.java:108)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
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:498)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy21.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:240)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.maven.bootstrap.ScannerBootstrapper.execute(ScannerBootstrapper.java:78)
at org.sonarsource.scanner.maven.SonarQubeMojo.execute(SonarQubeMojo.java:112)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
... 20 more
我该怎么做才能使我的分析不失败?
What should I do to get my analysis not failing?
推荐答案
版本4.0
引入了其API的更改,以便与SonarQube的新API保持一致5.6
LTS(长期支持).
Version 4.0
of the SonarQube Java Analyzer introduced changes in its API, in order to stay aligned with the new API of SonarQube 5.6
LTS (Long Term Support).
不幸的是,这些更改潜在地破坏了与直接依赖于Java分析器的插件的兼容性.如果PMD
和Checkstyle
插件的最新发行版本不受影响,则很遗憾,Findbugs
的3.3
版本与Cobertura
插件的1.6.3
版本不再兼容.
Unfortunately, these changes potentially broke compatibility with plugin directly relying on the Java Analyzer. If last released versions of PMD
and Checkstyle
plugins are not affected, version 3.3
of the Findbugs
is unfortunately not compatible anymore, as well as version 1.6.3
of the Cobertura
plugin.
为了解决Findbugs的问题,您可以使用以下选项:
In order to solve the issue with Findbugs, you have the following option:
- 更新到Findbugs插件的版本> =
3.4
,当前处于<strong>请求反馈期间(已通过版本3.4.2确认). - 删除Findbugs插件或暂时禁用其规则.
- Update to version >=
3.4
of the Findbugs plugin, which is currently in Request For Feedback period (see this thread), and should be released soon (confirmed with version 3.4.2). - Remove the Findbugs plugin or temporarily disable its rules.
对于Cobertura插件,请更新至版本> = 1.7
(需要LTS 5.6和Java 8),从而解决了该问题.应该可以使用SonarQube UI进行更新.
For the Cobertura plugin, update to version >= 1.7
(requires LTS 5.6 and Java 8), which solve the issue. The update should be available using the SonarQube UI.
这篇关于API与SonarQube 5.6和具有Findbugs 3.3或Cobertura 1.6.3的Java Analyzer 4.0不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!