Merge "Added version information to jar which can be used on the command line e.g. java -jar monasca-thresh.jar --version"

This commit is contained in:
Jenkins 2015-03-30 03:02:59 +00:00 committed by Gerrit Code Review
commit 51e27bab7d
2 changed files with 37 additions and 0 deletions

View File

@ -26,6 +26,8 @@
<skipITs>false</skipITs>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss</maven.build.timestamp.format>
<artifactNamedVersion>${project.artifactId}-${project.version}-${timestamp}-${buildNumber}
</artifactNamedVersion>
<shadedJarName>${project.artifactId}-${project.version}-shaded
@ -209,6 +211,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<packageName>monasca.thresh</packageName>
</manifest>
<manifestEntries>
<Implementation-Version>${artifactNamedVersion}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>

View File

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