- ALM used: Bitbucket Cloud
- CI system used AWS CodeBuild
- Scanner command used when applicable: mvn --settings aws/settings.xml sonar:sonar -e -Dskip.unit.tests=true -Dsonar.verbose=true -X -Dsonar.login=$LOGIN -Dsonar.host.url=$HOST -Dsonar.projectKey=$Project -Dsonar.organization=$Organization
- Languages of the repository: Java
Hi,
I have this Java project that is build in Java8 (not compatible with Java11), but I understand that SonarCloud accept only Java11 as runtime version.
I read a lot of topics as this one but I cannot find any solution.
Now I build in a step with java8 my project with:
mvn --settings aws/settings.xml clean install -P-validateCode
Then I try to run this command that from doc seems work with java8:
mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.login=$LOGIN -Dsonar.host.url=$HOST -Dsonar.projectKey=$Project -Dsonar.organization=$Organization -X
But It fails with the following error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar (default-cli) on project athena: 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
It seems that it needs also here Java11
So I have created a new step with java11 that take the source from the previous step (where the project is correctly compiled in java8) and I tried to run the following commands:
mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.login=$LOGIN -Dsonar.host.url=$HOST -Dsonar.projectKey=$Project -Dsonar.organization=$Organization -X
mvn --settings aws/settings.xml sonar:sonar -e -Dsonar.verbose=true -X -Dsonar.login=$LOGIN -Dsonar.host.url=$HOST -Dsonar.projectKey=$Project -Dsonar.organization=$Organization
It keeps failing, the last command fails with this error:
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar (default-cli) on project athena: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.0.2155:sonar (default-cli) on project athena: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.
My project is a multiple module project, the “mvn verify” is success on all modules except for the root one (if it is run on java8)
The “mvn sonar:sonar” fails in the root module and then it skips all the others.
How can I exclude the root module?