Use of Java 8 for running sonarqube plugin but not to run rest of build


(Timothy Meazell) #1

We have recently upgraded our Sonar instance to 5.6.4. This requires that analyses be run with Java 8 or higher. We would like to incorporate them into the rest of our build process. However, much of our existing code base will not compile on Java 8. How do I just run the sonarqube task on Java 8, but the rest of the build on an earlier version of Java.


(James Justinic) #2

It is not possible to run just the sonarqube task on Java 8. You would need to create an exec task to cross the process boundary and use the CLI sonar-scanner with Java 8. You lose all benefits of the plugin by doing this.

Instead, I would recommend that you just run the entire build on Java 8, but configure cross compilation so that your application code will still be compiled and tested with Java 7.

This will allow you to use any build plugins that have dropped support for Java 7 and be prepared for when Gradle does so as well, even if you must continue to use Java 7 for your application.


(Timothy Meazell) #3

Thanks so much, James. Went with the cross compilation as you suggest, seems to be doing the trick. Maybe on day our code base will enter the 21st century… :wink: