Skip to content

Commit 3cc1d27

Browse files
committed
Merge pull request #14764 from rjernst/utc_build_date
Override Build-Date in jar manifest to be ISO 8601
2 parents d538f0d + 759fc94 commit 3cc1d27

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*/
1919
package org.elasticsearch.gradle
2020

21+
import java.time.ZonedDateTime
22+
import java.time.ZoneOffset
23+
2124
import nebula.plugin.extraconfigurations.ProvidedBasePlugin
2225
import org.elasticsearch.gradle.precommit.PrecommitTasks
2326
import org.gradle.api.*
@@ -41,6 +44,7 @@ class BuildPlugin implements Plugin<Project> {
4144
project.pluginManager.apply('java')
4245
project.pluginManager.apply('carrotsearch.randomized-testing')
4346
// these plugins add lots of info to our jars
47+
configureJarManifest(project) // jar config must be added before info broker
4448
project.pluginManager.apply('nebula.info-broker')
4549
project.pluginManager.apply('nebula.info-basic')
4650
project.pluginManager.apply('nebula.info-java')
@@ -54,7 +58,7 @@ class BuildPlugin implements Plugin<Project> {
5458
configureConfigurations(project)
5559
project.ext.versions = VersionProperties.versions
5660
configureCompile(project)
57-
configureJarManifest(project)
61+
5862
configureTest(project)
5963
PrecommitTasks.configure(project)
6064
}
@@ -228,12 +232,14 @@ class BuildPlugin implements Plugin<Project> {
228232

229233
/** Adds additional manifest info to jars */
230234
static void configureJarManifest(Project project) {
231-
project.afterEvaluate {
232-
project.tasks.withType(Jar) { Jar jarTask ->
233-
manifest {
234-
attributes('X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch,
235-
'X-Compile-Lucene-Version': VersionProperties.lucene)
236-
}
235+
project.tasks.withType(Jar) { Jar jarTask ->
236+
jarTask.doFirst {
237+
// this doFirst is added before the info plugin, therefore it will run
238+
// after the doFirst added by the info plugin, and we can override attributes
239+
jarTask.manifest.attributes(
240+
'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch,
241+
'X-Compile-Lucene-Version': VersionProperties.lucene,
242+
'Build-Date': ZonedDateTime.now(ZoneOffset.UTC))
237243
}
238244
}
239245
}

0 commit comments

Comments
 (0)