Use reproducible method of generating properties file for better caching (#42539)

(cherry picked from commit 9772574f9d0b942a1ee8dba5ff503b4cd286e36c)
This commit is contained in:
Mark Vieira 2019-05-24 13:46:59 -07:00
parent 74d771d8f6
commit 5695992094
No known key found for this signature in database
GPG Key ID: CA947EF7E6D4B105
1 changed files with 9 additions and 13 deletions

View File

@ -45,21 +45,17 @@ if (project == rootProject) {
// we update the version property to reflect if we are building a snapshot or a release build
// we write this back out below to load it in the Build.java which will be shown in rest main action
// to indicate this being a snapshot build or a release build.
File propsFile = project.file('version.properties')
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(propsFile)
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('version.properties'))
version = props.getProperty("elasticsearch")
task generateVersionProperties(type: WriteProperties) {
outputFile = "${buildDir}/version.properties"
comment = 'Generated version properties'
properties(props)
}
processResources {
inputs.file(propsFile)
// We need to be explicit with the version because we add snapshot and qualifier to it based on properties
inputs.property("dynamic_elasticsearch_version", props.getProperty("elasticsearch"))
doLast {
Writer writer = file("$destinationDir/version.properties").newWriter()
try {
props.store(writer, "Generated version properties")
} finally {
writer.close()
}
}
from(generateVersionProperties)
}
/*****************************************************************************