From 2f0e0792fa0db960407242d0f00641fe3cba2b52 Mon Sep 17 00:00:00 2001 From: Dexter Fryar Date: Wed, 18 Mar 2015 23:43:44 +0000 Subject: [PATCH] Added version information to jar which can be used on the command line e.g. java -jar monasca-thresh.jar --version Change-Id: If1b6dc46ddac063d78b956fa43372cc4d30787fc --- thresh/pom.xml | 17 ++++++++++++++++ .../monasca/thresh/ThresholdingEngine.java | 20 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/thresh/pom.xml b/thresh/pom.xml index b8d6268..acdaf8b 100644 --- a/thresh/pom.xml +++ b/thresh/pom.xml @@ -21,6 +21,8 @@ false UTF-8 UTF-8 + ${maven.build.timestamp} + yyyy-MM-dd'T'HH:mm:ss ${project.artifactId}-${project.version}-${timestamp}-${buildNumber} ${project.artifactId}-${project.version}-shaded @@ -200,6 +202,21 @@ + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + monasca.thresh + + + ${artifactNamedVersion} + + + + org.apache.maven.plugins maven-shade-plugin diff --git a/thresh/src/main/java/monasca/thresh/ThresholdingEngine.java b/thresh/src/main/java/monasca/thresh/ThresholdingEngine.java index 1defe27..8095014 100644 --- a/thresh/src/main/java/monasca/thresh/ThresholdingEngine.java +++ b/thresh/src/main/java/monasca/thresh/ThresholdingEngine.java @@ -59,8 +59,20 @@ public class ThresholdingEngine { public static void main(String... args) throws Exception { + /* + * This should allow command line options to show the current version java + * -jar monasca-thresh.jar --version java -jar monasca-thresh.jar -version + * java -jar monasca-thresh.jar version Really anything with the word + * version in it will show the version as long as there is only one argument + */ + if (args.length == 1 && args[0].toLowerCase().contains("version")) { + showVersion(); + System.exit(0); + } + // Let's show the logging status. StatusPrinter.print((LoggerContext) LoggerFactory.getILoggerFactory()); + showVersion(); if (args.length < 2) { logger.error("Expected configuration file name and topology name arguments"); @@ -76,6 +88,14 @@ public class ThresholdingEngine { engine.run(); } + private static void showVersion() { + Package pkg; + pkg = Package.getPackage("monasca.thresh"); + + logger.info("-------- Version Information --------"); + logger.info("{}", pkg.getImplementationVersion()); + } + protected void configure() { Injector.registerModules(new TopologyModule(threshConfig)); }