Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (37 sloc) 1.24 KB
String compat(String src) {
if (src.contains('.')) {
src.substring(src.lastIndexOf('.')+1)
} else {
src
}
}
if (project.hasProperty('crossCompile')) {
// this will configure the java compile tasks with the appropriate JDK
project.afterEvaluate {
tasks.withType(JavaCompile) {
def version = compat(sourceCompatibility)
def jdkHome = System.getenv("JAVA_${version}")
if (!jdkHome) {
println "Warning: Please set path to JDK ${version} using environment variable JAVA_${version}"
println "Falling back to current JDK"
} else {
options.fork = true
options.forkOptions.javaHome = file(jdkHome)
doFirst {
println "$name compiles using JDK $version"
}
}
}
}
} else {
if (!JavaVersion.current().java9Compatible) {
throw new GradleException("You must use -PcrossCompile to enable cross compilation, or run Gradle with JDK 9")
}
project.afterEvaluate {
tasks.withType(JavaCompile) {
def version = compat(sourceCompatibility)
println "Configuring $name to use --release $version"
options.compilerArgs.addAll(['--release', version])
}
}
}
You can’t perform that action at this time.