Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: 3.2:sonar

Ron picture Ron · Oct 28, 2016 · Viewed 52.1k times · Source

Can anyone help me in getting solution for the below error.

Below are the version of the components to configure

  1. SonarQube 5.1.2
  2. Soanr-Runner 2.4
  3. Java 1.7 [ I have to use 1.7 only since my code supports only 1.7]
  4. mavn 3.3.9
  5. sonar-cobertura-plugin-1.6.3
  6. sonar-findbugs-plugin-3.3
  7. cobertura 2.6

Execution command

mvn -fn -e org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar -Dsonar.jdbc.url="jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance" -Dsonar.host.url=http://localhost:9000 -DskipTests

In Console Window I am getting error

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:
3.2:sonar (default-cli) on project NWT_Core: Execution default-cli of goal org.s
onarsource.scanner.maven:sonar-maven-plugin:3.2:sonar failed: Unable to load the
 mojo 'sonar' in the plugin 'org.sonarsource.scanner.maven:sonar-maven-plugin:3.
2' due to an API incompatibility: org.codehaus.plexus.component.repository.excep
tion.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 52.0 

Answer

Zzirconium picture Zzirconium · Oct 28, 2016

Since the 3.2, the SonarQube maven plugin requires Java 8. You have to use the 3.0.2 version for Java 7.

You have to explicitely add this statement to your pom :

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
    <version>3.0.2</version>
</plugin>

Because if you do not do so, by default this plugin uses the LATEST version of the plugin (3.2), hence your error.

See http://docs.sonarqube.org/display/HOME/Frequently+Asked+Questions#FrequentlyAskedQuestions-ShouldIlockversionofSonarQubeMavenplugininmypom.xml?