|
1 | 1 | package org.apache.hadoop.fs.glusterfs;
|
2 | 2 |
|
3 | 3 | import java.io.IOException;
|
4 |
| -import java.util.Properties; |
5 | 4 |
|
6 |
| -import org.slf4j.Logger; |
7 |
| -import org.slf4j.LoggerFactory; |
| 5 | +import java.util.Properties; |
8 | 6 |
|
| 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 | + */ |
9 | 12 | public class Version extends Properties{
|
10 |
| - final static Logger lg = LoggerFactory.getLogger(Version.class); |
11 | 13 | public Version() {
|
12 | 14 | super();
|
13 | 15 | try{
|
14 | 16 | load(this.getClass().getClassLoader().getResourceAsStream("git.properties"));
|
15 | 17 | }
|
16 | 18 | 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()); |
18 | 20 | }
|
19 | 21 | }
|
20 | 22 | public String getTag(){
|
21 | 23 | return this.getProperty("git.commit.id.describe").split("-")[0];
|
22 | 24 | }
|
| 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 | + } |
23 | 51 | }
|
0 commit comments