mirror of
https://github.com/corda/corda.git
synced 2024-12-19 21:17:58 +00:00
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.
This commit is contained in:
parent
c2585e8c8e
commit
9148d0529a
@ -1,17 +1,14 @@
|
||||
description 'Corda core (deterministic)'
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply from: '../deterministic.gradle'
|
||||
apply plugin: 'com.jfrog.artifactory'
|
||||
apply plugin: 'net.corda.plugins.publish-utils'
|
||||
apply plugin: 'idea'
|
||||
|
||||
evaluationDependsOn(':jdk8u-deterministic')
|
||||
evaluationDependsOn(":core")
|
||||
|
||||
def javaHome = System.getProperty('java.home')
|
||||
def jarBaseName = "corda-${project.name}".toString()
|
||||
def jdkTask = project(':jdk8u-deterministic').assemble
|
||||
def deterministic_jdk_home = project(':jdk8u-deterministic').jdk_home
|
||||
|
||||
configurations {
|
||||
runtimeLibraries
|
||||
@ -36,18 +33,6 @@ dependencies {
|
||||
runtimeLibraries "org.slf4j:slf4j-api:$slf4j_version"
|
||||
}
|
||||
|
||||
tasks.withType(AbstractCompile) {
|
||||
dependsOn jdkTask
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << '-bootclasspath' << "$deterministic_jdk_home/jre/lib/rt.jar".toString()
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
|
||||
kotlinOptions.jdkHome = deterministic_jdk_home
|
||||
}
|
||||
|
||||
jar {
|
||||
baseName 'DOES-NOT-EXIST'
|
||||
// Don't build a jar here because it would be the wrong one.
|
||||
@ -162,7 +147,7 @@ task metafix(type: MetaFixerTask) {
|
||||
task checkDeterminism(type: ProGuardTask, dependsOn: jdkTask) {
|
||||
injars metafix
|
||||
|
||||
libraryjars "$deterministic_jdk_home/jre/lib/rt.jar"
|
||||
libraryjars deterministic_rt_jar
|
||||
|
||||
configurations.runtimeLibraries.forEach {
|
||||
libraryjars it.path, filter: '!META-INF/versions/**'
|
||||
|
@ -1,29 +1,12 @@
|
||||
apply plugin: 'kotlin'
|
||||
apply from: '../../../deterministic.gradle'
|
||||
apply plugin: 'idea'
|
||||
|
||||
evaluationDependsOn(':jdk8u-deterministic')
|
||||
|
||||
def jdkTask = project(':jdk8u-deterministic').assemble
|
||||
def deterministic_jdk_home = project(':jdk8u-deterministic').jdk_home
|
||||
|
||||
dependencies {
|
||||
compileOnly project(path: ':core-deterministic', configuration: 'runtimeArtifacts')
|
||||
compileOnly project(path: ':serialization-deterministic', configuration: 'runtimeArtifacts')
|
||||
compileOnly "junit:junit:$junit_version"
|
||||
}
|
||||
|
||||
tasks.withType(AbstractCompile) {
|
||||
dependsOn jdkTask
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << '-bootclasspath' << "$deterministic_jdk_home/jre/lib/rt.jar".toString()
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
|
||||
kotlinOptions.jdkHome = deterministic_jdk_home
|
||||
}
|
||||
|
||||
idea {
|
||||
module {
|
||||
if (project.hasProperty("deterministic_idea_sdk")) {
|
||||
|
29
deterministic.gradle
Normal file
29
deterministic.gradle
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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
|
||||
}
|
@ -9,6 +9,7 @@ repositories {
|
||||
|
||||
ext {
|
||||
jdk_home = "$projectDir/jdk"
|
||||
rt_jar = "$jdk_home/jre/lib/rt.jar".toString()
|
||||
}
|
||||
|
||||
configurations {
|
||||
|
@ -1,17 +1,14 @@
|
||||
description 'Corda serialization (deterministic)'
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply from: '../deterministic.gradle'
|
||||
apply plugin: 'com.jfrog.artifactory'
|
||||
apply plugin: 'net.corda.plugins.publish-utils'
|
||||
apply plugin: 'idea'
|
||||
|
||||
evaluationDependsOn(':jdk8u-deterministic')
|
||||
evaluationDependsOn(":serialization")
|
||||
|
||||
def javaHome = System.getProperty('java.home')
|
||||
def jarBaseName = "corda-${project.name}".toString()
|
||||
def jdkTask = project(':jdk8u-deterministic').assemble
|
||||
def deterministic_jdk_home = project(':jdk8u-deterministic').jdk_home
|
||||
|
||||
configurations {
|
||||
runtimeLibraries
|
||||
@ -30,18 +27,6 @@ dependencies {
|
||||
runtimeLibraries "org.iq80.snappy:snappy:$snappy_version"
|
||||
}
|
||||
|
||||
tasks.withType(AbstractCompile) {
|
||||
dependsOn jdkTask
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-bootclasspath" << "$deterministic_jdk_home/jre/lib/rt.jar".toString()
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
|
||||
kotlinOptions.jdkHome = deterministic_jdk_home
|
||||
}
|
||||
|
||||
jar {
|
||||
baseName 'DOES-NOT-EXIST'
|
||||
// Don't build a jar here because it would be the wrong one.
|
||||
@ -150,7 +135,7 @@ task metafix(type: MetaFixerTask) {
|
||||
task checkDeterminism(type: ProGuardTask, dependsOn: jdkTask) {
|
||||
injars metafix
|
||||
|
||||
libraryjars "$deterministic_jdk_home/jre/lib/rt.jar"
|
||||
libraryjars deterministic_rt_jar
|
||||
|
||||
configurations.runtimeLibraries.forEach {
|
||||
libraryjars it.path, filter: '!META-INF/versions/**'
|
||||
|
Loading…
Reference in New Issue
Block a user