How to configure different java version for mvn and sonerscaner via mvn task in azure?

Hi guys,

I am using:
SonarQube 9.0 (upgraded recently to that version)
Azure DevOps + self-hosted agents with java 1.8 & java 11 / sonar-maven-plugin-3.9.0.2155 installed on it.
My app can only be build with java 1.8.

I am using Maven Task as part of Azure Pipeline to build the app and run Sonar Analysis as described below:
https://docs.sonarqube.org/latest/analysis/azuredevops-integration/

Since the upgrade on the SonarQube Server, i am getting following error:

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

Since both Build and Analysis of the app run as part of the same Maven task, I can’t find a way to run the build with java 1.8 and then the analysis with java 11.

Do you have any hints so as to how I could achieve that?

Thanks in advance!

Dilyan

Dear SonarSource Team,
I’m faced to the same situation blocking a lot of Java Pipelines for which Java engine is mandatory.
For the time being, I had to disable SonarQube control for all these pipelines.

Thanks to give the best option we can use to reimplement SonarQube control for these pipelines.
Fab

Dear Team,

I’m also getting same error. Please let me know if there is anyway to overwrite pass jdk version for sonar run separately and use different jdk version for build and sonar scan.

You should be able to run everything with Java 11, but specify these two properties in your pom.xml:

  • maven.compiler.source
  • maven.compiler.target

Both with the value “1.8”.