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

@@ -8,6 +8,8 @@ a30a3f89fbbea23deb5290e832eb0d12a8171ae8ba4461af2b936ed0245ee697 /com/fasterxml/
cd62bdfd946618c26b49451084361edf79cd6ddb3eae1a485ecb05319295896d /com/github/abrarsyed/jastyle/jAstyle/1.3/jAstyle-1.3.pom
33b3d79f3e27d33c46411ab7b7d81f43f12756e18c8936063f18b1a950a5f84b /com/github/jengelman/gradle/plugins/shadow/1.2.3/shadow-1.2.3.jar
f00facfc855e7d5517fc57553614b4690e61df9ab44f6e93ff583ae201b5a3aa /com/github/jengelman/gradle/plugins/shadow/1.2.3/shadow-1.2.3.pom
1e7bfcc83540c5af0fbab37ce316711380d142108f96db380e18a11e111cccf0 /com/github/johni0702/gradle-reproducible-builds-plugin/4989ae9/gradle-reproducible-builds-plugin-4989ae9.jar
8fe6e84a98417cbdc7df47b3afd5c368d7fb3139b4f0e16ac6f1496d85c24b18 /com/github/johni0702/gradle-reproducible-builds-plugin/4989ae9/gradle-reproducible-builds-plugin-4989ae9.pom
75ccc0e24d37ed5b8916e1bcffad1e067c2b1cfa21b635287f968db5c3c1963a /com/github/jponge/lzma-java/1.3/lzma-java-1.3.jar
fbcba81b21a8bc3c0761e4798fa05285444b43d681c03c9af49f9b2e1ecb0184 /com/github/jponge/lzma-java/1.3/lzma-java-1.3.pom
f38a7028bbac3f6c6b15cb40d533c96c6e8fdb54fc93d922cfa1931b25fa8c5c /com/github/replaymod/ReplayStudio/2df8d8b/ReplayStudio-2df8d8b.jar

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
}

View File

@@ -21,6 +21,7 @@ setup_dep () {
jarhash=$5
[ -f "deps/$dep.jar" ] && [ "$(sha256val "deps/$dep.jar")" == "$jarhash" ] && return
[ -f "deps/$dep.jar" ] && [ "*" == "$jarhash" ] && return
rm -rf "deps/$dep.jar"
if [ ! -d "deps/$dep" ] || [ "$(git -C "deps/$dep" rev-parse $commit^{commit})" != "$commit" ]; then
@@ -47,10 +48,14 @@ setup_dep () {
cp ../../../../gradlew .
chmod +x gradlew
./gradlew $PROXY_SETTINGS -I ../../init.gradle build -x test -x javadoc
if [ "$dep" == "proxy-witness" ]; then
./gradlew $PROXY_SETTINGS build -x test -x javadoc
else
./gradlew $PROXY_SETTINGS -I ../../init.gradle build -x test -x javadoc
fi
actual_hash=$(sha256val "$jar")
if [ "$actual_hash" != "$jarhash" ]; then
if [ "*" != "$jarhash" ] && [ "$actual_hash" != "$jarhash" ]; then
echo "Failed to verify checksum of build artifact of dependency: $dep"
echo "Expected: $jarhash"
echo "But was: $actual_hash"
@@ -63,7 +68,7 @@ setup_dep () {
}
# Setup http(s) proxy
setup_dep "proxy-witness" "https://github.com/johni0702/proxy-witness" "17ebb2e22f812faed9a28bae6bf1d8b28f798d56" "build/libs/proxy-witness.jar" "f6846fda75a35a55a38db7c3b8215ef43377c33af0ac8118318716223da10ecc"
setup_dep "proxy-witness" "https://github.com/johni0702/proxy-witness" "17ebb2e22f812faed9a28bae6bf1d8b28f798d56" "build/libs/proxy-witness.jar" "*"
java -Dproxywitness.httpUris=http://export.mcpbot.bspk.rs/versions.json -jar deps/proxy-witness.jar "$PROXY_PORT" checksums.txt > proxy.log 2>&1 &
proxy_pid=$!
trap "kill $proxy_pid" EXIT