protected static void addPropertiesFileToMap(URL url, Map<String, String> answer) throws AbortException { if (url != null) { try (InputStream in = url.openStream()) { Properties properties = new Properties(); properties.load(in); Map<String, String> map = toMap(properties); answer.putAll(map); } catch (IOException e) { throw new AbortException("Failed to load properties URL: " + url + ". " + e); } } }
protected static void addPropertiesFileToMap(URL url, Map<String, String> answer) throws AbortException { if (url != null) { try (InputStream in = url.openStream()) { Properties properties = new Properties(); properties.load(in); Map<String, String> map = toMap(properties); answer.putAll(map); } catch (IOException e) { throw new AbortException("Failed to load properties URL: " + url + ". " + e); } } }
protected static void addPropertiesFileToMap(File file, Map<String, String> answer) throws AbortException { if (file != null && file.isFile() && file.exists()) { try (FileInputStream in = new FileInputStream(file)) { Properties properties = new Properties(); properties.load(in); Map<String, String> map = toMap(properties); answer.putAll(map); } catch (IOException e) { throw new AbortException("Failed to load properties file: " + file + ". " + e); } } }
protected static void addPropertiesFileToMap(File file, Map<String, String> answer) throws AbortException { if (file != null && file.isFile() && file.exists()) { try (FileInputStream in = new FileInputStream(file)) { Properties properties = new Properties(); properties.load(in); Map<String, String> map = toMap(properties); answer.putAll(map); } catch (IOException e) { throw new AbortException("Failed to load properties file: " + file + ". " + e); } } }
private static Map<String, String> createConfigMapAnnotations(Session session, String status) { Map<String, String> annotations = new HashMap<>(); File dir = Util.getProjectBaseDir(session); String gitUrl = Util.findGitUrl(session, dir); annotations.put(Annotations.Tests.SESSION_ID, session.getId()); annotations.put(Annotations.Tests.TEST_SESSION_STATUS, status); if (Strings.isNotBlank(gitUrl)) { annotations.put(Annotations.Builds.GIT_URL, gitUrl); } // lets see if there's a maven generated set of pom properties File pomProperties = new File(dir, "target/maven-archiver/pom.properties"); if (pomProperties.isFile()) { try { Properties properties = new Properties(); properties.load(new FileInputStream(pomProperties)); Map<String, String> map = PropertiesHelper.toMap(properties); for (Map.Entry<String, String> entry : map.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (Strings.isNotBlank(key) && Strings.isNotBlank(value)) { annotations.put(Annotations.Project.PREFIX + key, value); } } } catch (IOException e) { session.getLogger().warn("Failed to load " + pomProperties + " file to annotate the namespace: " + e); } } return annotations; }