SonarScanner for Maven 5.0: Automatic JRE provisioning

We just released version 5.0 of the SonarScanner for Maven!
Now when connecting to a SonarQube Server >= 10.6 instance or to SonarQube Cloud, the scanner will download and cache a Java17 runtime from the server and use that runtime for the analysis.

This means that users will no longer need to have Java17 installed on their machines to run an analysis.

You can now benefit from this feature by specifying the plugin version to be >= 5.0 with the recommended command:

mvn org.sonarsource.scanner.maven:sonar-maven-plugin:<version>:sonar

F.A.Q.

How can I disable JRE provisioning?

1. Skip JRE provisioning altogether
The download of the provided JRE from the server can be skipped by providing this analysis parameter to the scanner
-Dsonar.scanner.skipJreProvisioning=true
With this property set the analysis will be run with the same JRE used to run Maven.

2. Provide your own JRE 17 to run the analysis
A specific JRE can also be defined to run the analysis with
-Dsonar.scanner.javaExePath="/path/to/jre"
This will also make the scanner skip the download of the JRE.

How can I modify JVM parameters for the analysis?
Java-specific parameters should now be provided with SONAR_SCANNER_JAVA_OPTS environment variables, e.g.:
export SONAR_SCANNER_JAVA_OPTS="-Xmx512m"

Or, as an analysis parameter
-Dsonar.scanner.javaOpts=”-Xmx512m”

More information on the scanner usage here

2 Likes

It work’s also via environment variable SONAR_SCANNER_SKIP_JRE_PROVISIONING set to true
i.e. in Jenkins via /manage/configure

[2024-11-07T15:02:32.587Z] [INFO] --- sonar:5.0.0.4389:sonar (default-cli) @ xxx ---
[...]
[2024-11-07T15:02:33.831Z] [INFO] JRE provisioning is disabled
[2024-11-07T15:02:33.831Z] [INFO] Using the java executable '/etc/alternatives/java_sdk_17_openjdk/bin/java' from JAVA_HOME
2 Likes