How to specify the minimum required Java update in Gradle?

I am creating a Java FX application that uses the Dialog classes added in Oracle JDK 1.8 in Update 40. Therefore, the minimum required version of Java is 1.8 u40 .

Now I want to provide this version in my Gradle build file. Obviously checking the major version with

 assert org.gradle.api.JavaVersion.current().isJava8Compatible() 

does not help in this case, since it omits the update number.

How to specify this opposition in the assembly file?

+5
source share
1 answer

Given the Opal suggestion, the following splits the version string and checks for the update number.

 if (javaVersion.startsWith("1.8.0") && javaVersion.split("_")[1].toInteger() < 40) { throw new GradleException("Java version 1.8.0_40 or later required, but was $javaVersion") } 
+2
source

All Articles