Skip to content

Commit 7804454

Browse files
committed
version properties , args, see main() comments for example usage.
1 parent 15b9b88 commit 7804454

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed
Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,51 @@
11
package org.apache.hadoop.fs.glusterfs;
22

33
import java.io.IOException;
4-
import java.util.Properties;
54

6-
import org.slf4j.Logger;
7-
import org.slf4j.LoggerFactory;
5+
import java.util.Properties;
86

7+
/**
8+
* Versioning stuff for the shim. This class is not tested since there is no
9+
* deterministic behaviour (i.e. it might not work if not building from binary),
10+
* and the effects are pure side effects.
11+
*/
912
public class Version extends Properties{
10-
final static Logger lg = LoggerFactory.getLogger(Version.class);
1113
public Version() {
1214
super();
1315
try{
1416
load(this.getClass().getClassLoader().getResourceAsStream("git.properties"));
1517
}
1618
catch(Throwable t){
17-
lg.error("Couldn't find git properties for version info " + t.getMessage());
19+
throw new RuntimeException("Couldn't find git properties for version info " + t.getMessage());
1820
}
1921
}
2022
public String getTag(){
2123
return this.getProperty("git.commit.id.describe").split("-")[0];
2224
}
25+
26+
/**
27+
* For use with terminal version checking.
28+
29+
Example, run with an argument to get single property:
30+
java -cp /home/Development/hadoop-glusterfs/glusterfs-2.0-SNAPSHOT.jar \
31+
org.apache.hadoop.fs.glusterfs.Version git.commit.id.describe | cut -d'-' -f 1
32+
33+
Or just run (no args, prints all properties)
34+
java -cp /home/Development/hadoop-glusterfs/glusterfs-2.0-SNAPSHOT.jar \
35+
*/
36+
public static void main(String[] args){
37+
Version v = new Version();
38+
//Dump the whole version info if no arg
39+
if(args.length==0){
40+
System.out.println(v);
41+
}
42+
//if specific arg given, print just that.
43+
else{
44+
String prop = v.get(args[0])+"";
45+
System.out.println(
46+
prop!=null?
47+
prop
48+
:"Couldnt find property "+prop);
49+
}
50+
}
2351
}

0 commit comments

Comments
 (0)