27c09b5005dec8dd979b51bc32ac46e13a1e9bb3
[portal/sdk.git] /
1 /*-
2  * ================================================================================
3  * ECOMP Portal SDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 package org.openecomp.portalsdk.analytics.system.fusion;
21
22 import java.io.IOException;
23 import java.util.Iterator;
24 import java.util.Map;
25 import java.util.jar.Attributes;
26 import java.util.jar.JarFile;
27 import java.util.jar.Manifest;
28
29 /**
30  * @author sundar 
31  * This class is used to get version and Build information when
32  *         user run "java -jar raptor_fusion.jar" command.
33  */
34 public class AntBuild {
35
36         public static void main(String[] args) {
37                 System.out.println("Jar (raptor_fusion.jar) Information: ");
38                 readManifest();
39         }
40
41         public static void readManifest() {
42                 try {
43                         JarFile jar = new JarFile("./raptor_fusion.jar");
44                         Manifest manifest = jar.getManifest();
45
46                         Attributes attribs = manifest.getMainAttributes();
47                         Iterator it = attribs.entrySet().iterator();
48                         while(it.hasNext()) {
49                                 Map.Entry entry = (Map.Entry) it.next();
50                                 Attributes.Name attributeName = (Attributes.Name) entry.getKey();
51                                 String attributeValue = (String) entry.getValue();
52                                 if (attributeName.toString().equals("Created-By"))
53                                         System.out.println("JDK Version " + " : " + attributeValue);
54                                 else if (attributeName.toString().equals("Ant-Version"))
55                                         System.out.println(attributeName.toString() + " : " + attributeValue);
56                                 else {
57                                         if(attributeName.toString().startsWith("Raptor"))
58                                                 System.out.println(attributeName.toString() + " : " + attributeValue);
59                                 }
60                         }
61
62                 } catch (IOException e) {
63                         System.err.println("Cannot read jar-file manifest: "
64                                         + e.getMessage());
65                 }
66         }
67 }