forked from I2P_Developers/i2p.i2p
Travis CI: Update config to handle cross-compilation
This commit is contained in:
39
build.gradle
39
build.gradle
@@ -40,6 +40,15 @@ String compat(String src) {
|
||||
}
|
||||
}
|
||||
|
||||
String javaExecutable(String targetJavaHome, String execName) {
|
||||
def javaExecutablesPath = new File(targetJavaHome, "bin")
|
||||
def executable = new File(javaExecutablesPath, execName)
|
||||
if (!executable.exists()) {
|
||||
throw new IllegalArgumentException("There is no ${execName} executable in ${javaExecutablesPath}")
|
||||
}
|
||||
executable.toString()
|
||||
}
|
||||
|
||||
def releaseVersion = getReleaseVersion()
|
||||
def buildVersion = getBuildVersion()
|
||||
def buildExtra = getBuildExtra()
|
||||
@@ -98,6 +107,36 @@ configure(javaProjects) {
|
||||
options.compilerArgs.addAll(['--release', version])
|
||||
}
|
||||
}
|
||||
|
||||
// Set up Java override if configured (used to test with Java 7).
|
||||
def targetJavaHome = System.getenv("TARGET_JAVA_HOME")
|
||||
if (targetJavaHome) {
|
||||
if (JavaVersion.current().java9Compatible) {
|
||||
throw new GradleException("Only set TARGET_JAVA_HOME with JDK 8")
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
logger.info("Target Java home set to ${targetJavaHome}")
|
||||
logger.info("Configuring Gradle to use forked compilation and testing")
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.fork = true
|
||||
options.forkOptions.javaHome = file(targetJavaHome)
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
executable = javaExecutable(targetJavaHome, "javadoc")
|
||||
}
|
||||
|
||||
tasks.withType(Test) {
|
||||
executable = javaExecutable(targetJavaHome, "java")
|
||||
}
|
||||
|
||||
tasks.withType(JavaExec) {
|
||||
executable = javaExecutable(targetJavaHome, "java")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task codeCoverageReport(type: JacocoReport) {
|
||||
|
Reference in New Issue
Block a user