From: jsimomaa Date: Thu, 22 Mar 2018 13:34:35 +0000 (+0200) Subject: Minor fixes for product build information querying X-Git-Tag: v1.43.0~136^2~528 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=9333c9691f828e8014a9c713cddbc51d95e05af3;p=simantics%2Fplatform.git Minor fixes for product build information querying refs #7828 Change-Id: Ibddcc305bce0d4e84f3fc684c80f3f65592374b6 --- diff --git a/bundles/org.simantics/src/org/simantics/BuildInfo.java b/bundles/org.simantics/src/org/simantics/BuildInfo.java index d3585642b..348f768fb 100644 --- a/bundles/org.simantics/src/org/simantics/BuildInfo.java +++ b/bundles/org.simantics/src/org/simantics/BuildInfo.java @@ -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 orderedProps = new TreeMap<>((o1, o2) -> o1.compareTo(o2)); + for (Entry entry : PROPS.entrySet()) + orderedProps.put(entry.getKey().toString(), entry.getValue().toString()); + for (Entry 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() : ""; + String productApplication = product.getApplication() != null ? product.getApplication() : ""; + String productDescription = product.getDescription() != null ? product.getDescription() : ""; + String productId = product.getId() != null ? product.getId() : ""; + + 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; } /**