corda/deterministic.gradle
Chris Rankin 9148d0529a
ENT-1463, ENT-1903: Refactor Gradle for deterministic modules (#3387)
* Export locations of both deterministic rt.jar and its JDK_HOME as properties.
* Refactor deterministic Java/Kotlin configuration into a script plugin.
2018-06-18 14:14:48 +01:00

30 lines
880 B
Groovy

/*
* Gradle script plugin: Configure a module such that the Java and Kotlin
* compilers use the deterministic rt.jar instead of the full JDK rt.jar.
*/
apply plugin: 'kotlin'
evaluationDependsOn(':jdk8u-deterministic')
def jdk8uDeterministic = project(':jdk8u-deterministic')
ext {
jdkTask = jdk8uDeterministic.assemble
deterministic_jdk_home = jdk8uDeterministic.jdk_home
deterministic_rt_jar = jdk8uDeterministic.rt_jar
}
tasks.withType(AbstractCompile) {
dependsOn jdkTask
// This is a bit ugly, but Gradle isn't recognising the KotlinCompile task
// as it does the built-in JavaCompile task.
if (it.class.name.startsWith("org.jetbrains.kotlin.gradle.tasks.KotlinCompile")) {
kotlinOptions.jdkHome = deterministic_jdk_home
}
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-bootclasspath' << deterministic_rt_jar
}