Github Actions for Java 8 projects


We have SonarQube 9.9 LTS version. I am trying to build and analyze the Java 8 project using maven wrapper mvnw in GitHub actions.
If I set Java 11 as $JAVA_HOME for SonarQube analysis then my maven wrapper also uses the same $JAVA_HOME to build.
Also, If I set $JAVA_HOME to 8 then the build is working but sonarqube is failing


I see two options here:

  • build and analyze in two separate steps (two separate mvn commands), each with its own Java version
  • run the whole thing with Java 11 and set the compile target to Java 8


if I set two separate builds this takes longer time to complete the two build plan because mvn sonar does not just analyze/scan the project like NodeJS project first sonar build and test then analyze the project.