1
2
3
4
5
6
7
8
9
10
11 package gov.bnl.gums.admin;
12
13 import java.io.File;
14 import java.net.URL;
15
16 import org.apache.commons.cli.Option;
17 import org.apache.commons.cli.Options;
18 import org.apache.commons.digester.Digester;
19
20 import gov.bnl.gums.GUMS;
21 import gov.bnl.gums.configuration.Version;
22
23
24
25
26
27 public class ClientVersion extends RemoteCommand {
28
29 static {
30 command = new ClientVersion();
31 }
32
33
34
35
36 public ClientVersion() {
37 syntax = "";
38 description = "Returns the version of GUMS client being used.";
39 }
40
41 protected org.apache.commons.cli.Options buildOptions() {
42 Options options = new Options();
43 return options;
44 }
45
46 protected void execute(org.apache.commons.cli.CommandLine cmd) throws Exception {
47 URL pomFile = getClass().getClassLoader().getSystemResource("META-INF/maven/gums/gums-core/pom.xml");
48 Digester digester = new Digester();
49 digester.addObjectCreate("project/version", Version.class);
50 digester.addCallMethod("project/version","setVersion",0);
51 Version versionCls = null;
52 try {
53 versionCls = (Version)digester.parse("file://"+pomFile.toString());
54 } catch (Exception e) {
55 System.out.println("Cannot get version from "+pomFile);
56 }
57 System.out.println("GUMS client version " + versionCls.getVersion());
58 }
59
60 }