Added java -jar monasca-api.jar --version

It is based on the timestamp and the last git commit

Change-Id: I20c7a074ed69666d6d237eda29cb44ca8f7ac41d
This commit is contained in:
Dexter Fryar 2015-03-19 13:54:24 -05:00 committed by Craig Bryant
parent ad1ab48b57
commit 23b9c9a1ef
3 changed files with 31 additions and 3 deletions

View File

@ -14,7 +14,10 @@
</prerequisites>
<properties>
<computedVersion>${project.version}-${timestamp}-${buildNumber}</computedVersion>
<gitRevision></gitRevision>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss</maven.build.timestamp.format>
<computedVersion>${project.version}-${timestamp}-${gitRevision}</computedVersion>
<computedName>${project.artifactId}-${computedVersion}</computedName>
<mon.common.version>1.0.0-SNAPSHOT</mon.common.version>
<dropwizard.version>0.7.0</dropwizard.version>
@ -336,8 +339,11 @@
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<packageName>monasca.api</packageName>
</manifest>
<manifestEntries>
<Implementation-Version>${project.artifactId}-${computedVersion}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>

View File

@ -61,9 +61,30 @@ import monasca.common.util.Injector;
*/
public class MonApiApplication extends Application<ApiConfig> {
public static void main(String[] args) throws Exception {
/*
* This should allow command line options to show the current version
* java -jar monasca-api.jar --version
* java -jar monasca-api.jar -version
* java -jar monasca-api.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);
}
new MonApiApplication().run(args);
}
private static void showVersion() {
Package pkg;
pkg = Package.getPackage("monasca.api");
System.out.println("-------- Version Information --------");
System.out.println(pkg.getImplementationVersion());
}
@Override
public void initialize(Bootstrap<ApiConfig> bootstrap) {
/** Configure bundles */

View File

@ -36,7 +36,8 @@ if [ $RUN_BUILD = "true" ]; then
fi
# Invoke the maven 3 on the real pom.xml
( cd java; ${MVN} $* )
( cd java; ${MVN} -DgitRevision=`git rev-list HEAD --max-count 1 --abbrev=0 --abbrev-commit` $* )
RC=$?
# Copy the jars where the publisher will find them