Running java 8 and 11 for Sonarcloud with CircleCI

Currently, we are using sonarcloud with CircleCI for our open-source project.

The scanner environment is going to require Java 11+ post-October 2020 and it requires some time for us to make code changes to support java 11.
Since we are still in java 8, we have to run the build with java 8 with CircleCI. I was going through few topics in forum on how to do this and with this comment I got to know that our build can still run with java 8 and only scanner command should run with java11.

Is there any documentation/steps that we can follow to have multiple java versions? and also is there any built docker image for this, so that we can use that image with CircleCI.

Hello @harshavardhanc,

This can be achieved as following:

  1. building your project with Java 8 in a first step
  2. persisting your target/ folder for Maven or build/ folder for Gradle in a first step
  3. extracting the persisted folder in a second step
  4. running the scanner with Java 11 in a second step

I created a sample maven project where I tried this out that you can look at:

1 Like

Thanks a lot, @TomVanBraband this will really helpful.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.