Search code examples
sonarqubesonar-runnermaven-cobertura-plugin

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


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 

Solution

  • Regardless of what you compile your code with, the SonarQube analysis should be run with a specific Java version.
    You simply need to use different JDK versions for the compilation and analysis.

    • For SonarQube 6.* compatibility], make sure the JAVA_HOME=/path/to/java8
    • For SonarQube 9.* compatibility], make sure the JAVA_HOME=/path/to/java11