]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Minor fixes for product build information querying 27/1627/2
authorjsimomaa <jani.simomaa@gmail.com>
Thu, 22 Mar 2018 13:34:35 +0000 (15:34 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 22 Mar 2018 16:07:11 +0000 (18:07 +0200)
refs #7828

Change-Id: Ibddcc305bce0d4e84f3fc684c80f3f65592374b6

bundles/org.simantics/src/org/simantics/BuildInfo.java

index d3585642b0ae73db5b841472206cc8e057c9996c..348f768fb815e4a032a309455686319edca9db77 100644 (file)
@@ -5,7 +5,9 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
+import java.util.TreeMap;
 import java.util.stream.Collectors;
 
 import org.eclipse.core.runtime.IProduct;
@@ -21,6 +23,7 @@ public final class BuildInfo {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(BuildInfo.class);
     private static final Properties PROPS;
+    private static final String ALL;
 
     public static final String DEFAULT_BUILDINFO_PROPERTIES_FILE = "buildinfo.properties";
     public static final String BUILDINFO_PROPERTIES_PROP = "buildinfo.properties.location";
@@ -49,15 +52,28 @@ public final class BuildInfo {
         collectInformationFromActiveProduct(buildinfo);
         
         PROPS = buildinfo;
+        StringBuilder sb = new StringBuilder();
+        TreeMap<String, String> orderedProps = new TreeMap<>((o1, o2) -> o1.compareTo(o2));
+        for (Entry<Object, Object> entry : PROPS.entrySet())
+            orderedProps.put(entry.getKey().toString(), entry.getValue().toString());
+        for (Entry<String, String> entry : orderedProps.entrySet()) {
+            sb.append(entry.getKey()).append("=").append(entry.getValue()).append("\n");
+        }
+        ALL = sb.toString();
     }
 
     private static void collectInformationFromActiveProduct(Properties buildinfo) {
         IProduct product = Platform.getProduct();
         if (product != null) {
-            buildinfo.setProperty("product.name", product.getName());
-            buildinfo.setProperty("product.application", product.getApplication());
-            buildinfo.setProperty("product.description", product.getDescription());
-            buildinfo.setProperty("product.id", product.getId());
+            String productName = product.getName() != null ? product.getName() : "<not-set>";
+            String productApplication = product.getApplication() != null ? product.getApplication() : "<not-set>";
+            String productDescription = product.getDescription() != null ? product.getDescription() : "<not-set>";
+            String productId = product.getId() != null ? product.getId() : "<not-set>";
+                
+            buildinfo.setProperty("product.name", productName);
+            buildinfo.setProperty("product.application", productApplication);
+            buildinfo.setProperty("product.description", productDescription);
+            buildinfo.setProperty("product.id", productId);
         }
     }
 
@@ -73,7 +89,7 @@ public final class BuildInfo {
      * @return
      */
     public static String all() {
-        return PROPS.toString();
+        return ALL;
     }
 
     /**