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