Build: Override Build-Date in jar manifest to be iso 8601

This commit is contained in:
Ryan Ernst 2015-11-14 22:38:10 -08:00
parent c09103c35b
commit 759fc94947
1 changed files with 13 additions and 7 deletions

View File

@ -18,6 +18,9 @@
*/ */
package org.elasticsearch.gradle package org.elasticsearch.gradle
import java.time.ZonedDateTime
import java.time.ZoneOffset
import nebula.plugin.extraconfigurations.ProvidedBasePlugin import nebula.plugin.extraconfigurations.ProvidedBasePlugin
import org.elasticsearch.gradle.precommit.PrecommitTasks import org.elasticsearch.gradle.precommit.PrecommitTasks
import org.gradle.api.* import org.gradle.api.*
@ -41,6 +44,7 @@ class BuildPlugin implements Plugin<Project> {
project.pluginManager.apply('java') project.pluginManager.apply('java')
project.pluginManager.apply('carrotsearch.randomized-testing') project.pluginManager.apply('carrotsearch.randomized-testing')
// these plugins add lots of info to our jars // these plugins add lots of info to our jars
configureJarManifest(project) // jar config must be added before info broker
project.pluginManager.apply('nebula.info-broker') project.pluginManager.apply('nebula.info-broker')
project.pluginManager.apply('nebula.info-basic') project.pluginManager.apply('nebula.info-basic')
project.pluginManager.apply('nebula.info-java') project.pluginManager.apply('nebula.info-java')
@ -54,7 +58,7 @@ class BuildPlugin implements Plugin<Project> {
configureConfigurations(project) configureConfigurations(project)
project.ext.versions = VersionProperties.versions project.ext.versions = VersionProperties.versions
configureCompile(project) configureCompile(project)
configureJarManifest(project)
configureTest(project) configureTest(project)
PrecommitTasks.configure(project) PrecommitTasks.configure(project)
} }
@ -228,12 +232,14 @@ class BuildPlugin implements Plugin<Project> {
/** Adds additional manifest info to jars */ /** Adds additional manifest info to jars */
static void configureJarManifest(Project project) { static void configureJarManifest(Project project) {
project.afterEvaluate { project.tasks.withType(Jar) { Jar jarTask ->
project.tasks.withType(Jar) { Jar jarTask -> jarTask.doFirst {
manifest { // this doFirst is added before the info plugin, therefore it will run
attributes('X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch, // after the doFirst added by the info plugin, and we can override attributes
'X-Compile-Lucene-Version': VersionProperties.lucene) jarTask.manifest.attributes(
} 'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch,
'X-Compile-Lucene-Version': VersionProperties.lucene,
'Build-Date': ZonedDateTime.now(ZoneOffset.UTC))
} }
} }
} }