Skip to content

Commit

Permalink
Use reproducible method of generating properties file for better cach…
Browse files Browse the repository at this point in the history
…ing (elastic#42539)
  • Loading branch information
mark-vieira authored and Gurkan Kaymak committed May 27, 2019
1 parent c4e6e92 commit 5805585
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/*****************************************************************************
Expand Down

0 comments on commit 5805585

Please sign in to comment.