CID-251: Integrate DJVM with Corda's existing deterministic-rt. (#3846)

* Integrate DJVM with Corda's existing deterministic-rt.
* Remove generated whitelists from DJVM.
* Fix Manifest attributes, disable jar tasks and attach shadowJar to assemble task.
This commit is contained in:
Chris Rankin 2018-08-24 15:51:40 +01:00 committed by GitHub
parent 8b0fc8f29c
commit 329c9da0a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 71 deletions

View File

@ -1,20 +1,10 @@
buildscript { plugins {
// Shaded version of ASM to avoid conflict with root project. id 'com.github.johnrengelman.shadow' version '2.0.4'
ext.asm_version = '6.1.1'
ext.deterministic_rt_version = '1.0-20180625.120901-7'
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.3'
}
} }
plugins { ext {
id 'com.github.johnrengelman.shadow' version '2.0.3' // Shaded version of ASM to avoid conflict with root project.
asm_version = '6.1.1'
} }
dependencies { dependencies {
@ -32,47 +22,16 @@ dependencies {
// Classpath scanner // Classpath scanner
compile "io.github.lukehutch:fast-classpath-scanner:$fast_classpath_scanner_version" compile "io.github.lukehutch:fast-classpath-scanner:$fast_classpath_scanner_version"
// Deterministic runtime - used in whitelist generation
runtime "net.corda:deterministic-rt:$deterministic_rt_version:api"
// Test utilities // Test utilities
testCompile "junit:junit:$junit_version" testCompile "junit:junit:$junit_version"
testCompile "org.assertj:assertj-core:$assertj_version" testCompile "org.assertj:assertj-core:$assertj_version"
} }
repositories { jar.enabled = false
mavenLocal()
mavenCentral()
maven {
url "$artifactory_contextUrl/corda-dev"
}
}
task generateWhitelist(type: JavaExec) {
// This is an example of how a whitelist can be generated from a JAR. In most applications though, it is recommended
// thet the minimal set whitelist is used.
def jars = configurations.runtime.collect {
it.toString()
}.findAll {
it.toString().contains("deterministic-rt")
}
classpath = sourceSets.main.runtimeClasspath
main = 'net.corda.djvm.tools.cli.Program'
args = ['whitelist', 'generate', '-o', 'src/main/resources/jdk8-deterministic.dat.gz'] + jars
}
jar {
manifest {
attributes(
'Automatic-Module-Name': 'net.corda.djvm'
)
}
}
shadowJar { shadowJar {
baseName = "djvm" baseName = "djvm"
classifier = "" classifier = ""
exclude 'deterministic-rt*.jar'
dependencies { dependencies {
exclude(dependency('com.jcabi:.*:.*')) exclude(dependency('com.jcabi:.*:.*'))
exclude(dependency('org.apache.*:.*:.*')) exclude(dependency('org.apache.*:.*:.*'))
@ -87,3 +46,4 @@ shadowJar {
} }
} }
} }
assemble.dependsOn shadowJar

View File

@ -1,16 +1,15 @@
buildscript { plugins {
repositories { id 'com.github.johnrengelman.shadow'
mavenCentral() }
jcenter()
} repositories {
dependencies { maven {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" url "$artifactory_contextUrl/corda-dev"
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.3'
} }
} }
plugins { configurations {
id 'com.github.johnrengelman.shadow' deterministicRt
} }
dependencies { dependencies {
@ -23,23 +22,29 @@ dependencies {
compile "info.picocli:picocli:$picocli_version" compile "info.picocli:picocli:$picocli_version"
compile "io.github.lukehutch:fast-classpath-scanner:$fast_classpath_scanner_version" compile "io.github.lukehutch:fast-classpath-scanner:$fast_classpath_scanner_version"
compile project(path: ":djvm", configuration: "shadow") compile project(path: ":djvm", configuration: "shadow")
// Deterministic runtime - used in whitelist generation
deterministicRt project(path: ':jdk8u-deterministic', configuration: 'jdk')
} }
repositories { jar.enabled = false
mavenLocal()
mavenCentral()
}
jar {
manifest {
attributes(
'Main-Class': 'net.corda.djvm.tools.cli.Program',
'Automatic-Module-Name': 'net.corda.djvm',
'Build-Date': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
)
}
}
shadowJar { shadowJar {
baseName = "corda-djvm" baseName = "corda-djvm"
classifier = 'cli'
manifest {
attributes(
'Automatic-Module-Name': 'net.corda.djvm',
'Main-Class': 'net.corda.djvm.tools.cli.Program',
'Build-Date': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
)
}
}
assemble.dependsOn shadowJar
task generateWhitelist(type: JavaExec, dependsOn: shadowJar) {
// This is an example of how a whitelist can be generated from a JAR. In most applications though, it is recommended
// that the minimal set whitelist is used.
main = '-jar'
args = [shadowJar.outputs.files.singleFile, 'whitelist', 'generate', '-o', "$buildDir/jdk8-deterministic.dat.gz", configurations.deterministicRt.files[0] ]
} }

View File

@ -45,3 +45,7 @@ task copyJdk(type: Copy) {
assemble.dependsOn copyJdk assemble.dependsOn copyJdk
jar.enabled = false jar.enabled = false
artifacts {
jdk file: file(rt_jar), type: 'jar', builtBy: copyJdk
}