From 7a3ae1d3814fc8bf457a6da198e68c6cb8da7cfe Mon Sep 17 00:00:00 2001 From: "Michael N. Lipp" Date: Tue, 1 Aug 2023 12:25:37 +0200 Subject: [PATCH] Add version information. --- build.gradle | 6 ++---- ....vmoperator.java-common-conventions.gradle | 19 +++++++++++++++++++ .../jdrupes/vmoperator/manager/Operator.java | 5 +++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 20c844f..7225e7e 100644 --- a/build.gradle +++ b/build.gradle @@ -2,13 +2,11 @@ buildscript { repositories { gradlePluginPortal() } - dependencies { - classpath 'org.ajoberstar.grgit:grgit-gradle:4.1.0' - classpath 'org.ajoberstar:gradle-git-publish:3.0.0' - } } plugins { + id 'org.ajoberstar.grgit' version '5.2.0' + id 'org.ajoberstar.git-publish' version '4.2.0' id 'pl.allegro.tech.build.axion-release' version '1.15.0' apply false id 'org.jdrupes.vmoperator.java-doc-conventions' id 'eclipse' diff --git a/buildSrc/src/org.jdrupes.vmoperator.java-common-conventions.gradle b/buildSrc/src/org.jdrupes.vmoperator.java-common-conventions.gradle index 74fc72b..48017f9 100644 --- a/buildSrc/src/org.jdrupes.vmoperator.java-common-conventions.gradle +++ b/buildSrc/src/org.jdrupes.vmoperator.java-common-conventions.gradle @@ -13,6 +13,9 @@ plugins { // Apply eclipse plugin id 'eclipse' + + // Access to git information + id 'org.ajoberstar.grgit' } repositories { @@ -66,6 +69,22 @@ scmVersion { version = scmVersion.version ext.isSnapshot = version.endsWith('-SNAPSHOT') +jar { + manifest { + inputs.property("gitDescriptor", { grgit.describe(always: true) }) + + // Set Git revision information in the manifests of built bundles + attributes([ + "Implementation-Title": project.name, + "Implementation-Version": "$project.version (${grgit.describe(always: true)})", + "Implementation-Vendor": grgit.repository.jgit.repository.config.getString("user", null, "name") + + " (" + grgit.repository.jgit.repository.config.getString("user", null, "email") + ")", + "Git-Descriptor": grgit.describe(always: true), + "Git-SHA": grgit.head().id, + ]) + } +} + eclipse { project { diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Operator.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Operator.java index 24476fd..ddcb45f 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Operator.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Operator.java @@ -23,6 +23,8 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.util.logging.LogManager; +import java.util.logging.Logger; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; @@ -106,6 +108,9 @@ public class Operator extends Component { */ @SuppressWarnings("PMD.SignatureDeclareThrowsException") public static void main(String[] args) throws Exception { + Logger.getLogger(Operator.class.getName()) + .fine(() -> "Version: " + + Operator.class.getPackage().getImplementationVersion()); CommandLineParser parser = new DefaultParser(); // parse the command line arguments final Options options = new Options();