Conversation with Merlin [email protected] · Wed Nov 08 2023

sonar cube build error+[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar (default-cli) on project policy-insights-handler: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar: java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

The error message you encountered indicates an API incompatibility issue while executing the SonarQube build with the Sonar Maven plugin. The root cause seems to be a version mismatch between the Java Runtime used to compile the project and the version supported by the Java Runtime on your system.

The error message specifically mentions that the class "org.sonar.batch.bootstrapper.EnvironmentInformation" has been compiled with a more recent version of the Java Runtime (class file version 55.0 while your Java Runtime only recognizes class file versions up to 52.0.

To resolve this issue, you can try the following steps:

  1. Verify Java versions: Check the Java version used for compilation and the Java version installed on your system. Make sure they are compatible. You can use the "java -version" command in your terminal to check the Java version.

  2. Update Java: If the installed Java version is outdated, consider updating it to a newer version that is compatible with the Java version used for compilation.

  3. Configure Maven compiler plugin: In some cases, the default Java version used by Maven might not match the installed Java version on your system. You can specify the Java version explicitly in the Maven compiler plugin configuration in your project's pom.xml file. For example:

<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <!-- Replace with the correct Java version --> <target>1.8</target> <!-- Replace with the correct Java version --> </configuration> </plugin> ... </plugins> ... </build> ... </project>

Replace "1.8" with the appropriate Java version that is compatible with your system.

  1. Verify SonarQube compatibility: Ensure that the version ofarQube you are using is compatible with the Java version you have installed. Check the SonarQube documentation for compatibility details.

By following these steps, you should be able to resolve the API incompatibility issue and successfully execute the SonarQube build.