Use gradle-reproducible-builds-plugin instead of configuring Gradle manually

This commit is contained in:
Jonas Herzig
2017-09-03 15:13:59 +02:00
parent c21408a9d0
commit 5be2f36a78
3 changed files with 20 additions and 29 deletions

View File

@@ -2,6 +2,15 @@ import java.util.jar.JarEntry
import java.util.jar.JarFile
import java.util.jar.JarOutputStream
initscript {
repositories {
maven { url 'http://jitpack.io' }
}
dependencies {
classpath 'com.github.johni0702:gradle-reproducible-builds-plugin:4989ae9'
}
}
def convertRepoToHttp = { repo ->
if (repo instanceof MavenArtifactRepository && repo.url.toString().startsWith('https://')) {
URL url = repo.url.toURL()
@@ -14,30 +23,5 @@ allprojects {
repositories.all convertRepoToHttp
}
repositories.all convertRepoToHttp
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
dirMode = 0775
fileMode = 0664
}
// The shadow plugin doesn't seem to support the above
def shadowJar = tasks.findByPath ':shadowJar'
if (shadowJar != null) {
shadowJar.doLast {
File newFile = new File(archivePath.parent, 'tmp-' + archiveName)
newFile.withOutputStream { fout ->
JarOutputStream out = new JarOutputStream(fout)
JarFile jf = new JarFile(archivePath)
jf.entries().unique {it.name}.sort {it.name}.each {
def copy = new JarEntry(it.name)
copy.time = 0
out.putNextEntry(copy)
out << jf.getInputStream(it)
}
out.finish()
}
newFile.renameTo archivePath
}
}
apply plugin: de.johni0702.gradle.ReproducibleBuildsPlugin, to: project
}