Skip to content

Commit 5695992

Browse files
committed
Use reproducible method of generating properties file for better caching (#42539)
(cherry picked from commit 9772574)
1 parent 74d771d commit 5695992

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

buildSrc/build.gradle

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,17 @@ if (project == rootProject) {
4545
// we update the version property to reflect if we are building a snapshot or a release build
4646
// we write this back out below to load it in the Build.java which will be shown in rest main action
4747
// to indicate this being a snapshot build or a release build.
48-
File propsFile = project.file('version.properties')
49-
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(propsFile)
48+
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('version.properties'))
5049
version = props.getProperty("elasticsearch")
50+
51+
task generateVersionProperties(type: WriteProperties) {
52+
outputFile = "${buildDir}/version.properties"
53+
comment = 'Generated version properties'
54+
properties(props)
55+
}
56+
5157
processResources {
52-
inputs.file(propsFile)
53-
// We need to be explicit with the version because we add snapshot and qualifier to it based on properties
54-
inputs.property("dynamic_elasticsearch_version", props.getProperty("elasticsearch"))
55-
doLast {
56-
Writer writer = file("$destinationDir/version.properties").newWriter()
57-
try {
58-
props.store(writer, "Generated version properties")
59-
} finally {
60-
writer.close()
61-
}
62-
}
58+
from(generateVersionProperties)
6359
}
6460

6561
/*****************************************************************************

0 commit comments

Comments
 (0)