mirror of
https://github.com/corda/corda.git
synced 2025-04-12 05:40:48 +00:00
Sorting of files. Create build.gradle in contracts. Comments.
This commit is contained in:
parent
cbfcac994a
commit
e34731bad7
67
build.gradle
67
build.gradle
@ -1,12 +1,3 @@
|
||||
import com.google.common.io.ByteStreams
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.nio.file.attribute.FileTime
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
group 'com.r3cev.prototyping'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
@ -36,8 +27,6 @@ buildscript {
|
||||
|
||||
// Dokka (JavaDoc equivalent for Kotlin) download is huge so just comment this out for now.
|
||||
//classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.6"
|
||||
|
||||
classpath "com.google.guava:guava:19.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,59 +117,3 @@ task runDemoSeller(type: JavaExec, dependsOn: ':classes') {
|
||||
args = ['--dir=seller', '--fake-trade-with=localhost', '--network-address=localhost:31338',
|
||||
'--timestamper-identity-file=buyer/identity-public', '--timestamper-address=localhost']
|
||||
}
|
||||
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()
|
||||
|
||||
def output = new ZipOutputStream(new FileOutputStream(destPath.toFile()))
|
||||
output.setMethod(ZipOutputStream.STORED)
|
||||
|
||||
while (entries.hasMoreElements()) {
|
||||
def entry = entries.nextElement()
|
||||
|
||||
def newEntry = new ZipEntry( entry.name )
|
||||
|
||||
newEntry.setLastModifiedTime(zeroTime)
|
||||
newEntry.setCreationTime(zeroTime)
|
||||
newEntry.compressedSize = -1
|
||||
newEntry.size = entry.size
|
||||
newEntry.crc = entry.crc
|
||||
|
||||
output.putNextEntry(newEntry)
|
||||
|
||||
ByteStreams.copy(input.getInputStream(entry), output)
|
||||
|
||||
output.closeEntry()
|
||||
}
|
||||
output.close()
|
||||
input.close()
|
||||
|
||||
Files.move(destPath, Paths.get(zipPath), StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
project(':contracts') {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
apply plugin: CanonicalizerPlugin
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile rootProject
|
||||
}
|
||||
}
|
||||
|
74
contracts/build.gradle
Normal file
74
contracts/build.gradle
Normal file
@ -0,0 +1,74 @@
|
||||
import com.google.common.io.ByteStreams
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.nio.file.attribute.FileTime
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "com.google.guava:guava:19.0"
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
apply plugin: CanonicalizerPlugin
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile rootProject
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user