/** * load the runtime values * @param prefix prefix to place before them * @since 1.10.4 */ protected void loadRuntime(String prefix) { Properties props = new Properties(); if (!prefix.endsWith(".")) { prefix += "."; } log("Loading Runtime properties " + prefix, Project.MSG_VERBOSE); Runtime r = Runtime.getRuntime(); props.put(prefix + "availableProcessors", String.valueOf(r.availableProcessors())); props.put(prefix + "freeMemory", String.valueOf(r.freeMemory())); props.put(prefix + "maxMemory", String.valueOf(r.maxMemory())); props.put(prefix + "totalMemory", String.valueOf(r.totalMemory())); addProperties(props); }
/** * load the environment values * @param prefix prefix to place before them */ protected void loadEnvironment(String prefix) { Properties props = new Properties(); if (!prefix.endsWith(".")) { prefix += "."; } log("Loading Environment " + prefix, Project.MSG_VERBOSE); Map<String, String> osEnv = Execute.getEnvironmentVariables(); for (Map.Entry<String, String> entry : osEnv.entrySet()) { props.put(prefix + entry.getKey(), entry.getValue()); } addProperties(props); }
/** * load properties from a url * @param url url to load from * @throws BuildException on error */ protected void loadUrl(URL url) throws BuildException { Properties props = new Properties(); log("Loading " + url, Project.MSG_VERBOSE); try { try (InputStream is = url.openStream()) { loadProperties(props, is, url.getFile().endsWith(".xml")); } addProperties(props); } catch (IOException ex) { throw new BuildException(ex, getLocation()); } }
/** * load properties from a file * @param file file to load * @throws BuildException on error */ protected void loadFile(File file) throws BuildException { Properties props = new Properties(); log("Loading " + file.getAbsolutePath(), Project.MSG_VERBOSE); try { if (file.exists()) { try (InputStream fis = Files.newInputStream(file.toPath())) { loadProperties(props, fis, file.getName().endsWith(".xml")); } addProperties(props); } else { log("Unable to find property file: " + file.getAbsolutePath(), Project.MSG_VERBOSE); } } catch (IOException ex) { throw new BuildException(ex, getLocation()); } }
propertyTask.setPrefix(prefix); propertyTask.setPrefixValues(prefixValues); propertyTask.addProperties(props);
addProperties(props); } else { log("Unable to find resource " + name, Project.MSG_WARN);
@Override public void // Make this method publicly accessible. addProperties(Properties props) { super.addProperties(props); } }