Failed to execute goal org.sonarsource.scanner.mav

2019-08-12 20:44发布

问题:

I installed Sonar PMD plugin and after which i am getting the following error:

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar (default-cli) on project bpm-parent:
  Execution default goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1:sonar failed:
  An API incompatibility was encountered while executing org.sonarscanner.maven:sonar-maven-plugin:3.0.1:sonar:
  java.lang.NoSuchMethodError: org.sonar.plugins.java.api.JavaResourceLocator.classpath()Ljava/llection;
-----------------------------------------------------
realm = plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.1
strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
urls[0] = file:/C:/Users/yogas/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.0.1/sonar-maven-plugin-3.0.1.jar
urls[1] = file:/C:/Users/yogas/.m2/repository/org/apache/maven/shared/maven-dependency-tree/2.2/maven-dependency-tree-2.2.jar
urls[2] = file:/C:/Users/yogas/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.ja
urls[3] = file:/C:/Users/yogas/.m2/repository/org/eclipse/aether/aether-util/0.9.0.M2/aether-util-0.9.0.M2.jar
urls[4] = file:/C:/Users/yogas/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
urls[5] = file:/C:/Users/yogas/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
urls[6] = file:/C:/Users/yogas/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
urls[7] = file:/C:/Users/yogas/.m2/repository/org/sonarsource/sonar-runner/sonar-runner-api/2.5.1/sonar-runner-api-2.5.1.jar
urls[8] = file:/C:/Users/yogas/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
urls[9] = file:/C:/Users/yogas/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar
urls[10] = file:/C:/Users/yogas/.m2/repository/com/google/code/findbugs/jsr305/2.0.3/jsr305-2.0.3.jar
Number of foreign imports: 1
  import: Entry[import  from realm ClassRealm[maven.api, parent: null]]             

回答1:

This seems pretty straightforward:

An API incompatibility was encountered...

Generally, you should check the Plugin Version Matrix to make sure the plugin version you want to install is compatible with your version of the server.

Specifically in this case however, it seems to be an incompatibility between the version of the PMD plugin and the version of the Java plugin, on which it is dependent (Thanks Julien!). Try making sure you have the latest versions of both installed.