CORDA-2902: Remove the CanonicalizerPlugin from buildSrc. ()

This commit is contained in:
Chris Rankin 2019-04-30 14:17:25 +01:00 committed by josecoll
parent cb85dd1e92
commit 531493325c
7 changed files with 13 additions and 81 deletions
buildSrc
confidential-identities
finance
contracts
workflows
isolated

View File

@ -1,22 +0,0 @@
plugins {
id 'groovy'
id 'java-gradle-plugin'
}
repositories {
mavenLocal()
mavenCentral()
}
gradlePlugin {
plugins {
canonicalizerPlugin {
id = 'net.corda.plugins.canonicalizer'
implementationClass = 'CanonicalizerPlugin'
}
}
}
dependencies {
compile "com.google.guava:guava:$guava_version"
}

View File

@ -1,52 +0,0 @@
import com.google.common.io.ByteStreams
import org.gradle.api.*
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import java.util.zip.ZipOutputStream
import java.nio.file.Files
import java.nio.file.attribute.FileTime
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
// Custom Gradle plugin that attempts to make the resulting jar file deterministic.
// Ie. same contract definition should result when compiled in same jar file.
// This is done by removing date time stamps from the files inside the jar.
class CanonicalizerPlugin implements Plugin<Project> {
void apply(Project project) {
project.getTasks().getByName('jar').doLast() {
def zipPath = (String) project.jar.archivePath
def destPath = Files.createTempFile("processzip", null)
def zeroTime = FileTime.fromMillis(0)
def input = new ZipFile(zipPath)
def entries = input.entries().toList().sort { it.name }
def output = new ZipOutputStream(new FileOutputStream(destPath.toFile()))
output.setMethod(ZipOutputStream.DEFLATED)
entries.each {
def newEntry = new ZipEntry(it.name)
newEntry.setLastModifiedTime(zeroTime)
newEntry.setCreationTime(zeroTime)
newEntry.compressedSize = -1
newEntry.size = it.size
newEntry.crc = it.crc
output.putNextEntry(newEntry)
ByteStreams.copy(input.getInputStream(it), output)
output.closeEntry()
}
output.close()
input.close()
Files.move(destPath, Paths.get(zipPath), StandardCopyOption.REPLACE_EXISTING)
}
}
}

View File

@ -1,4 +1,3 @@
rootProject.name = 'buildSrc' rootProject.name = 'buildSrc'
include 'canonicalizer'
apply from: '../buildCacheSettings.gradle' apply from: '../buildCacheSettings.gradle'

View File

@ -1,7 +1,6 @@
// This contains the SwapIdentitiesFlow which can be used for exchanging confidential identities as part of a flow. // This contains the SwapIdentitiesFlow which can be used for exchanging confidential identities as part of a flow.
// TODO: Merge this into core: the original plan was to develop it independently but in practice it's too widely used to break compatibility now, as finance uses it. // TODO: Merge this into core: the original plan was to develop it independently but in practice it's too widely used to break compatibility now, as finance uses it.
apply plugin: 'kotlin' apply plugin: 'kotlin'
apply plugin: CanonicalizerPlugin
apply plugin: 'net.corda.plugins.publish-utils' apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'net.corda.plugins.quasar-utils' apply plugin: 'net.corda.plugins.quasar-utils'
apply plugin: 'net.corda.plugins.cordapp' apply plugin: 'net.corda.plugins.cordapp'
@ -27,6 +26,8 @@ dependencies {
jar { jar {
baseName 'corda-confidential-identities' baseName 'corda-confidential-identities'
preserveFileTimestamps = false
reproducibleFileOrder = true
} }
publish { publish {

View File

@ -2,7 +2,6 @@ apply plugin: 'kotlin'
// Java Persistence API support: create no-arg constructor // Java Persistence API support: create no-arg constructor
// see: http://stackoverflow.com/questions/32038177/kotlin-with-jpa-default-constructor-hell // see: http://stackoverflow.com/questions/32038177/kotlin-with-jpa-default-constructor-hell
apply plugin: 'kotlin-jpa' apply plugin: 'kotlin-jpa'
apply plugin: CanonicalizerPlugin
apply plugin: 'net.corda.plugins.publish-utils' apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'net.corda.plugins.quasar-utils' apply plugin: 'net.corda.plugins.quasar-utils'
apply plugin: 'net.corda.plugins.cordapp' apply plugin: 'net.corda.plugins.cordapp'
@ -27,6 +26,8 @@ configurations {
jar { jar {
baseName 'corda-finance-contracts' baseName 'corda-finance-contracts'
preserveFileTimestamps = false
reproducibleFileOrder = true
manifest { manifest {
attributes('Corda-Revision': 'n/a') attributes('Corda-Revision': 'n/a')
attributes('Corda-Vendor': 'Corda Open Source') attributes('Corda-Vendor': 'Corda Open Source')

View File

@ -2,7 +2,6 @@ apply plugin: 'kotlin'
// Java Persistence API support: create no-arg constructor // Java Persistence API support: create no-arg constructor
// see: http://stackoverflow.com/questions/32038177/kotlin-with-jpa-default-constructor-hell // see: http://stackoverflow.com/questions/32038177/kotlin-with-jpa-default-constructor-hell
apply plugin: 'kotlin-jpa' apply plugin: 'kotlin-jpa'
apply plugin: CanonicalizerPlugin
apply plugin: 'net.corda.plugins.publish-utils' apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'net.corda.plugins.quasar-utils' apply plugin: 'net.corda.plugins.quasar-utils'
apply plugin: 'net.corda.plugins.cordapp' apply plugin: 'net.corda.plugins.cordapp'
@ -65,6 +64,8 @@ artifacts {
jar { jar {
baseName 'corda-finance-workflows' baseName 'corda-finance-workflows'
preserveFileTimestamps = false
reproducibleFileOrder = true
} }
configurations { configurations {

View File

@ -1,5 +1,4 @@
apply plugin: 'kotlin' apply plugin: 'kotlin'
apply plugin: CanonicalizerPlugin
apply plugin: 'net.corda.plugins.cordapp' apply plugin: 'net.corda.plugins.cordapp'
description 'Isolated CorDapp for testing' description 'Isolated CorDapp for testing'
@ -8,6 +7,11 @@ dependencies {
cordaCompile project(':core') cordaCompile project(':core')
} }
jar {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
cordapp { cordapp {
targetPlatformVersion corda_platform_version.toInteger() targetPlatformVersion corda_platform_version.toInteger()
minimumPlatformVersion 1 minimumPlatformVersion 1