1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-25 22:02:05 +01:00

Make builds reproducible

This commit is contained in:
Paul Schaub 2021-06-24 18:58:24 +02:00
parent 8a4908d29d
commit 9c8a2a0b29

View file

@ -1,5 +1,3 @@
import java.text.SimpleDateFormat
buildscript { buildscript {
repositories { repositories {
@ -55,11 +53,16 @@ allprojects {
mavenCentral() mavenCentral()
} }
// Reproducible Builds
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
project.ext { project.ext {
junitVersion = '5.7.1' junitVersion = '5.7.1'
rootConfigDir = new File(rootDir, 'config') rootConfigDir = new File(rootDir, 'config')
gitCommit = getGitCommit() gitCommit = getGitCommit()
builtDate = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date())
isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI')) isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
isReleaseVersion = !isSnapshot isReleaseVersion = !isSnapshot
signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment) signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment)
@ -188,9 +191,10 @@ subprojects {
doLast { doLast {
def propertiesFile = file "$generatedVersionDir/version.properties" def propertiesFile = file "$generatedVersionDir/version.properties"
propertiesFile.parentFile.mkdirs() propertiesFile.parentFile.mkdirs()
def properties = new Properties() propertiesFile.createNewFile()
properties.setProperty("version", rootProject.version.toString()) // Instead of using a Properties object here, we directly write to the file
propertiesFile.withWriter { properties.store(it, null) } // since Properties adds a timestamp, ruining reproducibility
propertiesFile.write("version="+rootProject.version.toString())
} }
} }
processResources.dependsOn generateVersionProperties processResources.dependsOn generateVersionProperties