Set up cross-compilation for JDK 9+

This commit is contained in:
Jack Grigg
2019-02-16 13:01:15 +00:00
parent ebe99afe57
commit 2a64794a05
2 changed files with 30 additions and 2 deletions

View File

@ -17,6 +17,14 @@ allprojects {
project.ext.i2pVersion = '0.9.33'
String compat(String src) {
if (src.contains('.')) {
src.substring(src.lastIndexOf('.') + 1)
} else {
src
}
}
configure([project(':core'), project(':webapp')]) {
project.version = '0.4.7'
@ -29,11 +37,31 @@ configure([project(':core'), project(':webapp')]) {
sourceCompatibility = 1.7
targetCompatibility = 1.7
// Set i2pBootClasspath=/path/to/rt.jar:/path/to/jce.jar in ~/.gradle/gradle.properties if needed
def i2pBootClasspath
// Set java7BootClasspath=/path/to/rt.jar:/path/to/jce.jar in ~/.gradle/gradle.properties if needed
if (java7BootClasspath) {
i2pBootClasspath = java7BootClasspath
} else {
def java7Home = System.getenv("JAVA7_HOME")
if (java7Home) {
i2pBootClasspath = "${java7Home}/jre/lib/jce.jar:${java7Home}/jre/lib/rt.jar"
}
}
if (i2pBootClasspath) {
project.tasks.withType(AbstractCompile, { AbstractCompile ac ->
ac.options.bootstrapClasspath = files(i2pBootClasspath)
})
} else {
if (JavaVersion.current().java8Compatible && !JavaVersion.current().java9Compatible) {
throw new GradleException("Set java7BootClasspath property or JAVA7_HOME environment variable to enable cross-compilation, or run Gradle with JDK 9+")
}
tasks.withType(JavaCompile) {
def version = compat(sourceCompatibility)
println "Configuring $name to use --release $version"
options.compilerArgs.addAll(['--release', version])
}
}
}
}

View File

@ -1,2 +1,2 @@
# Override these in ~/.gradle/gradle.properties if necessary
i2pBootClasspath=
java7BootClasspath=