From fbbc7565d43013153e429da57fc9ace0c4871782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 28 Jul 2023 14:56:17 +0200 Subject: [PATCH] Create a commit hash for local builds as well (#2673) --- tycho-spi/pom.xml | 17 +++++++++++++++++ .../org/eclipse/tycho/version/TychoVersion.java | 8 +++++++- .../eclipse/tycho/version/version.properties | 4 +++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tycho-spi/pom.xml b/tycho-spi/pom.xml index b75cb14ff0..01d87e60fa 100644 --- a/tycho-spi/pom.xml +++ b/tycho-spi/pom.xml @@ -57,6 +57,23 @@ org.apache.maven.plugins maven-plugin-plugin + + org.codehaus.mojo + buildnumber-maven-plugin + 3.1.0 + + + validate + + create + + + + + false + false + + diff --git a/tycho-spi/src/main/java/org/eclipse/tycho/version/TychoVersion.java b/tycho-spi/src/main/java/org/eclipse/tycho/version/TychoVersion.java index 71eb106006..482b420c53 100644 --- a/tycho-spi/src/main/java/org/eclipse/tycho/version/TychoVersion.java +++ b/tycho-spi/src/main/java/org/eclipse/tycho/version/TychoVersion.java @@ -22,6 +22,8 @@ public class TychoVersion { private static final String TYCHO_SCM = readVersion("scm"); + private static final String TYCHO_BUILDNUMBER = readVersion("buildNumber"); + private static final String BND_VERSION = readVersion("bnd"); private static Properties PROPERTIES; @@ -36,7 +38,11 @@ public static String getBndVersion() { public static String getSCMInfo() { if ("${env.GIT_COMMIT}".equals(TYCHO_SCM)) { - return "local build"; + if ("${buildNumber}".equals(TYCHO_BUILDNUMBER)) { + //no way then... + return "local build"; + } + return TYCHO_BUILDNUMBER; } return TYCHO_SCM; } diff --git a/tycho-spi/src/main/resources/org/eclipse/tycho/version/version.properties b/tycho-spi/src/main/resources/org/eclipse/tycho/version/version.properties index 0d5dc6ade2..fcb02b3da4 100644 --- a/tycho-spi/src/main/resources/org/eclipse/tycho/version/version.properties +++ b/tycho-spi/src/main/resources/org/eclipse/tycho/version/version.properties @@ -2,4 +2,6 @@ version=${project.version} bnd=${bnd.version} scm=${env.GIT_COMMIT} url=${env.GIT_URL} -branch=${env.GIT_BRANCH} \ No newline at end of file +branch=${env.GIT_BRANCH} +scmBranch=${scmBranch} +buildNumber=${buildNumber}