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;
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";
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);
}
}
* @return
*/
public static String all() {
- return PROPS.toString();
+ return ALL;
}
/**