mirror of
https://github.com/corda/corda.git
synced 2024-12-21 22:07:55 +00:00
406f7ff292
This requires Kotlin 1.2 versions of core and serialization (core-1.2 and serialization-1.2 respectively), which are just "shell" modules and which compile the existing source code with Kotlin 1.2. The 1.2 plugin does not work with the current version of Gradle and so the 1.2 compiler has to be called directly. Now with two versions of Kotlin in the code base, each module needs to have its version manually specified to ensure a clean separation. Otherwise, the default Kotlin version can override 1.2 when needed. Some of the code was tidied-up or improved to enable it to be cross-compiled. For post-1.2 APIs being used, they have been copied into core-1.2 with the same method signatures. OpenTelemetryComponent was moved to node-api, along with the dependency, to avoid also having a 1.2 version for the opentelemetry module.
131 lines
3.8 KiB
Groovy
131 lines
3.8 KiB
Groovy
apply plugin: 'org.jetbrains.kotlin.jvm'
|
|
apply plugin: 'net.corda.plugins.cordapp'
|
|
|
|
def javaHome = System.getProperty('java.home')
|
|
def shrinkJar = file("$buildDir/libs/${project.name}-${project.version}-tiny.jar")
|
|
|
|
|
|
import net.corda.plugins.SignJar
|
|
import proguard.gradle.ProGuardTask
|
|
|
|
import java.security.MessageDigest
|
|
import java.security.NoSuchAlgorithmException
|
|
|
|
static String sha256(File jarFile) throws FileNotFoundException, NoSuchAlgorithmException {
|
|
InputStream input = new FileInputStream(jarFile)
|
|
try {
|
|
MessageDigest digest = MessageDigest.getInstance("SHA-256")
|
|
byte[] buffer = new byte[8192]
|
|
int bytesRead
|
|
while ((bytesRead = input.read(buffer)) != -1) {
|
|
digest.update(buffer, 0, bytesRead)
|
|
}
|
|
return digest.digest().encodeHex().toString()
|
|
} finally {
|
|
input.close()
|
|
}
|
|
}
|
|
|
|
cordapp {
|
|
targetPlatformVersion = corda_platform_version.toInteger()
|
|
minimumPlatformVersion 1
|
|
signing {
|
|
// Cordapp is signed after the "shrink" task.
|
|
enabled false
|
|
}
|
|
sealing {
|
|
// Cannot seal JAR because other module also defines classes in the package net.corda.vega.analytics
|
|
enabled false
|
|
}
|
|
contract {
|
|
name "net/corda/vega/contracts"
|
|
versionId 1
|
|
vendor "R3"
|
|
licence "Open Source (Apache 2)"
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
shrinkArtifacts
|
|
}
|
|
|
|
dependencies {
|
|
// The SIMM demo CorDapp depends upon Cash CorDapp features
|
|
cordapp project(':finance:contracts')
|
|
|
|
// Corda integration dependencies
|
|
cordaProvided project(':core')
|
|
|
|
|
|
// Cordapp dependencies
|
|
// Specify your cordapp's dependencies below, including dependent cordapps
|
|
implementation "com.opengamma.strata:strata-product:$strata_version"
|
|
implementation "com.opengamma.strata:strata-market:$strata_version"
|
|
}
|
|
|
|
configurations.cordapp.canBeResolved = true
|
|
tasks.register('generateDependencies') {
|
|
dependsOn project(':finance:contracts').tasks.jar
|
|
def cordappDependencies = file("${sourceSets.main.output.resourcesDir}/META-INF/Cordapp-Dependencies")
|
|
inputs.files(configurations.cordapp)
|
|
outputs.files(cordappDependencies)
|
|
doLast {
|
|
cordappDependencies.newWriter().withWriter { writer ->
|
|
configurations.cordapp.forEach { cordapp ->
|
|
writer << sha256(cordapp) << System.lineSeparator()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
processResources.finalizedBy generateDependencies
|
|
|
|
jar {
|
|
archiveClassifier = 'fat'
|
|
}
|
|
|
|
tasks.register('shrink', ProGuardTask) {
|
|
injars jar
|
|
outjars shrinkJar
|
|
|
|
libraryjars "$javaHome/jmods"
|
|
configurations.runtimeClasspath.forEach {
|
|
libraryjars it.path, filter: '!META-INF/versions/**'
|
|
}
|
|
|
|
dontwarn 'afu.org.checkerframework.**'
|
|
dontwarn 'co.paralleluniverse.**'
|
|
dontwarn 'org.checkerframework.**'
|
|
dontwarn 'org.joda.**'
|
|
dontnote
|
|
|
|
// We need to preserve our CorDapp's own directory structure so that Corda
|
|
// can find the contract classes.
|
|
keepdirectories 'net/corda/**'
|
|
keepattributes '*'
|
|
dontobfuscate
|
|
dontoptimize
|
|
verbose
|
|
|
|
// These are our CorDapp classes, so don't change these.
|
|
keep 'class net.corda.vega.** { *; }', includedescriptorclasses: true
|
|
|
|
// Until CorDapps are isolated from each other, we need to ensure that the
|
|
// versions of the classes that this CorDapp needs are still usable by other
|
|
// CorDapps. Unfortunately, this means that we cannot shrink them as much as
|
|
// we'd like to.
|
|
keepclassmembers 'class com.opengamma.strata.** { *; }', includedescriptorclasses: true
|
|
keepclassmembers 'class com.google.** { *; }', includedescriptorclasses: true
|
|
keepclassmembers 'class org.joda.** { *; }', includedescriptorclasses: true
|
|
}
|
|
|
|
tasks.register('sign', SignJar) {
|
|
inputJars shrink
|
|
}
|
|
|
|
jar.finalizedBy shrink
|
|
shrink.finalizedBy sign
|
|
|
|
artifacts {
|
|
shrinkArtifacts shrinkJar
|
|
}
|