CORDA-2876: Ensure that sandboxable byte-code is compiled for Java 8.

This commit is contained in:
Chris Rankin 2019-11-14 16:22:28 +00:00
parent 4a8c73bf4a
commit b1c164e26d
2 changed files with 23 additions and 2 deletions

View File

@ -1,3 +1,5 @@
import static org.gradle.api.JavaVersion.VERSION_1_8
/* /*
* Gradle script plugin: Configure a module such that the Java and Kotlin * 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. * compilers use the deterministic rt.jar instead of the full JDK rt.jar.
@ -19,11 +21,16 @@ tasks.withType(AbstractCompile) {
// This is a bit ugly, but Gradle isn't recognising the KotlinCompile task // This is a bit ugly, but Gradle isn't recognising the KotlinCompile task
// as it does the built-in JavaCompile task. // as it does the built-in JavaCompile task.
if (it.class.name.startsWith("org.jetbrains.kotlin.gradle.tasks.KotlinCompile")) { if (it.class.name.startsWith('org.jetbrains.kotlin.gradle.tasks.KotlinCompile')) {
kotlinOptions.jdkHome = deterministic_jdk_home kotlinOptions {
jdkHome = deterministic_jdk_home
jvmTarget = VERSION_1_8
}
} }
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
options.compilerArgs << '-bootclasspath' << deterministic_rt_jar options.compilerArgs << '-bootclasspath' << deterministic_rt_jar
sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8
} }

View File

@ -1,3 +1,5 @@
import static org.gradle.api.JavaVersion.VERSION_1_8
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' id 'org.jetbrains.kotlin.jvm'
id 'net.corda.plugins.publish-utils' id 'net.corda.plugins.publish-utils'
@ -42,6 +44,18 @@ dependencies {
sandboxTesting "org.slf4j:slf4j-nop:$slf4j_version" sandboxTesting "org.slf4j:slf4j-nop:$slf4j_version"
} }
// The DJVM only supports Java 8 byte-code.
compileTestJava {
sourceCompatibility = VERSION_1_8
targetCompatibility = VERSION_1_8
}
compileTestKotlin {
kotlinOptions {
jvmTarget = VERSION_1_8
}
}
jar { jar {
archiveBaseName = 'corda-serialization-djvm' archiveBaseName = 'corda-serialization-djvm'
manifest { manifest {