public void mergeProperties(File file, boolean override) { if (file.isFile()) { try { Properties properties = loadProperties(file); mergeProperties(properties, override); } catch (Exception e) { error("Error loading properties file: " + file); } } else { if (!file.exists()) error("Properties file does not exist: " + file); else error("Properties file must a file, not a directory: " + file); } }
public String _error(String args[]) { for (int i = 1; i < args.length; i++) { domain.error(process(args[i])); } return ""; }
public void mergeProperties(File file, boolean override) { if (file.isFile()) { try { Properties properties = loadProperties(file); mergeProperties(properties, override); } catch (Exception e) { error("Error loading properties file: " + file); } } else { if (!file.exists()) error("Properties file does not exist: " + file); else error("Properties file must a file, not a directory: " + file); } }
public String _error(String args[]) { for (int i = 1; i < args.length; i++) { domain.error(process(args[i])); } return ""; }
Properties loadProperties(InputStream in, String name) throws IOException { int n = name.lastIndexOf('/'); if (n > 0) name = name.substring(0, n); if (name.length() == 0) name = "."; try { Properties p = new Properties(); p.load(in); return replaceAll(p, "\\$\\{\\.\\}", name); } catch (Exception e) { error("Error during loading properties file: " + name + ", error:" + e); return new Properties(); } }
Properties loadProperties(InputStream in, String name) throws IOException { int n = name.lastIndexOf('/'); if (n > 0) name = name.substring(0, n); if (name.length() == 0) name = "."; try { Properties p = new Properties(); p.load(in); return replaceAll(p, "\\$\\{\\.\\}", name); } catch (Exception e) { error("Error during loading properties file: " + name + ", error:" + e); return new Properties(); } }
private String doCommand(Object target, String method, String[] args) { if (target == null) ; // System.out.println("Huh? Target should never be null " + // domain); else { String cname = "_" + method.replaceAll("-", "_"); try { Method m = target.getClass().getMethod(cname, new Class[] { String[].class }); return (String) m.invoke(target, new Object[] { args }); } catch (NoSuchMethodException e) { // Ignore } catch (InvocationTargetException e) { if ( e.getCause() instanceof IllegalArgumentException ) { domain.error("%s, for cmd: %s, arguments; %s", e.getMessage(), method, Arrays.toString(args)); } else { domain.warning("Exception in replace: " + e.getCause()); e.getCause().printStackTrace(); } } catch (Exception e) { domain.warning("Exception in replace: " + e + " method=" + method); e.printStackTrace(); } } return null; }
public void setProperties(File propertiesFile, File base) { this.propertiesFile = propertiesFile.getAbsoluteFile(); setBase(base); try { if (propertiesFile.isFile()) { // System.out.println("Loading properties " + propertiesFile); long modified = propertiesFile.lastModified(); if (modified > System.currentTimeMillis() + 100) { System.out.println("Huh? This is in the future " + propertiesFile); this.modified = System.currentTimeMillis(); } else this.modified = modified; included = null; Properties p = loadProperties(propertiesFile); setProperties(p); } else { if (fileMustExist) { error("No such properties file: " + propertiesFile); } } } catch (IOException e) { error("Could not load properties " + propertiesFile); } }
public void setProperties(File propertiesFile, File base) { this.propertiesFile = propertiesFile.getAbsoluteFile(); setBase(base); try { if (propertiesFile.isFile()) { // System.out.println("Loading properties " + propertiesFile); long modified = propertiesFile.lastModified(); if (modified > System.currentTimeMillis() + 100) { System.out.println("Huh? This is in the future " + propertiesFile); this.modified = System.currentTimeMillis(); } else this.modified = modified; included = null; Properties p = loadProperties(propertiesFile); setProperties(p); } else { if (fileMustExist) { error("No such properties file: " + propertiesFile); } } } catch (IOException e) { error("Could not load properties " + propertiesFile); } }
/** * System command. Execute a command and insert the result. * * @param args * @param help * @param patterns * @param low * @param high */ public String system_internal(boolean allowFail, String args[]) throws Exception { verifyCommand(args, "${" + (allowFail ? "system-allow-fail" : "system") + ";<command>[;<in>]}, execute a system command", null, 2, 3); String command = args[1]; String input = null; if (args.length > 2) { input = args[2]; } Process process = Runtime.getRuntime().exec(command, null, domain.getBase()); if (input != null) { process.getOutputStream().write(input.getBytes("UTF-8")); } process.getOutputStream().close(); String s = IO.collect(process.getInputStream(), "UTF-8"); int exitValue = process.waitFor(); if (!allowFail && (exitValue != 0)) { domain.error("System command " + command + " failed with " + exitValue); } return s.trim(); }
int exitValue = process.waitFor(); if (exitValue != 0) { domain.error("System command " + command + " failed with " + exitValue);
/** * @param file * @param parent * @param done * @param overwrite * @throws FileNotFoundException * @throws IOException */ public void doIncludeFile(File file, boolean overwrite, Properties target) throws Exception { if (included != null && included.contains(file)) { error("Cyclic or multiple include of " + file); } else { addIncluded(file); updateModified(file.lastModified(), file.toString()); InputStream in = new FileInputStream(file); Properties sub; if (file.getName().toLowerCase().endsWith(".mf")) { sub = getManifestAsProperties(in); } else sub = loadProperties(in, file.getAbsolutePath()); in.close(); doIncludes(file.getParentFile(), sub); // make sure we do not override properties for (Map.Entry<?, ?> entry : sub.entrySet()) { if (overwrite || !target.containsKey(entry.getKey())) target.setProperty((String) entry.getKey(), (String) entry.getValue()); } } }
public String _range(String args[]) { verifyCommand(args, _rangeHelp, _rangePattern, 2, 3); Version version = null; if (args.length >= 3) version = new Version(args[2]); String spec = args[1]; Matcher m = RANGE_MASK.matcher(spec); m.matches(); String floor = m.group(1); String floorMask = m.group(2); String ceilingMask = m.group(3); String ceiling = m.group(4); StringBuilder sb = new StringBuilder(); sb.append(floor); sb.append(version(version, floorMask)); sb.append(","); sb.append(version(version, ceilingMask)); sb.append(ceiling); String s = sb.toString(); VersionRange vr = new VersionRange(s); if (!(vr.includes(vr.getHigh()) || vr.includes(vr.getLow()))) { domain.error("${range} macro created an invalid range %s from %s and mask %s", s, version, spec); } return sb.toString(); }
if (v == null) { domain .error( "No version specified for ${version} or ${range} and no implicit version ${@} either, mask=%s", mask);
reporter.error(error); return false;