Add version information.

This commit is contained in:
Michael Lipp 2023-08-01 12:25:37 +02:00
parent e1b52da239
commit 7a3ae1d381
3 changed files with 26 additions and 4 deletions

View file

@ -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'

View file

@ -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 {

View file

@ -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();