From f498bf8e8f7546aa77d2644f83604291c4a00a49 Mon Sep 17 00:00:00 2001 From: Karsten Thoms Date: Tue, 9 Jan 2018 15:41:08 +0100 Subject: [PATCH] [529291] Replace @build@ token in about.mappings Signed-off-by: Karsten Thoms --- gradle/eclipse-project-layout.gradle | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gradle/eclipse-project-layout.gradle b/gradle/eclipse-project-layout.gradle index cf6cf4382..d10eac313 100644 --- a/gradle/eclipse-project-layout.gradle +++ b/gradle/eclipse-project-layout.gradle @@ -1,3 +1,4 @@ +import org.apache.tools.ant.filters.* /* * Since we use the Eclipse Style layout where sources and resources live in the same * folders, we need to make some adjustments to Gradle's defaults. @@ -42,12 +43,46 @@ if (isTestProject) { jar { from ('.') { include 'about*.*', 'plugin.xml', 'schema/**', 'model/**', 'plugin.properties' + exclude 'about.mappings' + } + from ('.') { + include 'about.mappings' + filter(ReplaceTokens, tokens: ['build': getBuildId()]) } if (isTestProject) { from sourceSets.test.output } } +/** + * Computes the build type from the project version. + * When property 'upstreamBranch' has been set the build type is 'I'. + * + * @return I,M,R (Integration, Milestone, Release) + */ +def String getBuildType () { + if (hasProperty('upstreamBranch')) { + return 'I' + } + + def versionSplit = version.split('\\.') + if (version.endsWith('SNAPSHOT')) + return 'I' + else if (versionSplit.length == 4) + return 'M' + else + return 'R' +} + +/** + * Computes a build identifier as a combination of the build type + * (Integration,Milestone/Release) and the build timestamp. + */ +def getBuildId () { + return getBuildType()+buildTime +} + + sourcesJar { from ('.') { include 'about*.*'