Does Gradle expose the java version of the JDK/JRE used for the build?

I am developing a module as part of a mutli-module project that needs Java8 whereas the rest of the modules need Java7. What I’d ideally love to do is to say, in settings.gradle, that if “java version being used is >=8, then include module” otherwise don’t.

Gradle doesn’t expose any specific API for this but you can simply check the ‘java.version’ system property from the settings.gradle file.

We actually do, it’s [‘JavaVersion’](http://www.gradle.org/docs/current/javadoc/org/gradle/api/JavaVersion.html).

1 Like

Awesome Luke! Thanks!

Mark, yeah I realized I could go that route. Was just looking for something a little more OO. Thanks all!

Understood. I had forgotten that we provided that as a public API. Luke’s suggestion is definitely superior to goofy system prop string comparison.