Gradle Plugin Not Handling Java Version

Running Gradle (7.4.2) with the following plugin.
id “org.sonarqube” version “3.3”

When running gradle sonarqube I get the following error.

* What went wrong:
Execution failed for task ':app:sonarqube'.
> 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

Per the documentation:

The most common case is to run the analysis with Java 11, while the project itself uses Java 8 or before for its build. This case is normally automatically handled when using Maven or Gradle, as well as with any flavor of SonarLint.

The gradle plugin does not seem to be automatically handling the Java version.

Hey there.

Take a look at the documentation on Scanner Environment.

It looks like you are running your build with Java 8 – you will need to make sure that either your entire build is being run with Java 11 (targeting Java 8), or that Java 11 is specifically used for the SonarQube portion of your build.