18
18
*/
19
19
package org.elasticsearch.gradle
20
20
21
+ import java.time.ZonedDateTime
22
+ import java.time.ZoneOffset
23
+
21
24
import nebula.plugin.extraconfigurations.ProvidedBasePlugin
22
25
import org.elasticsearch.gradle.precommit.PrecommitTasks
23
26
import org.gradle.api.*
@@ -41,6 +44,7 @@ class BuildPlugin implements Plugin<Project> {
41
44
project. pluginManager. apply(' java' )
42
45
project. pluginManager. apply(' carrotsearch.randomized-testing' )
43
46
// these plugins add lots of info to our jars
47
+ configureJarManifest(project) // jar config must be added before info broker
44
48
project. pluginManager. apply(' nebula.info-broker' )
45
49
project. pluginManager. apply(' nebula.info-basic' )
46
50
project. pluginManager. apply(' nebula.info-java' )
@@ -54,7 +58,7 @@ class BuildPlugin implements Plugin<Project> {
54
58
configureConfigurations(project)
55
59
project. ext. versions = VersionProperties . versions
56
60
configureCompile(project)
57
- configureJarManifest(project)
61
+
58
62
configureTest(project)
59
63
PrecommitTasks . configure(project)
60
64
}
@@ -228,12 +232,14 @@ class BuildPlugin implements Plugin<Project> {
228
232
229
233
/* * Adds additional manifest info to jars */
230
234
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 ))
237
243
}
238
244
}
239
245
}
0 commit comments