public static processFile(String inputName, String outputName) { pipe(new FileInputStream(inputFile), new FileOutputStream(outputFile), new Zip(), new Sed(), new Unzip()); }
boolean replace(File f, String pattern, String replacement) throws IOException { final Macro macro = getReplacer(); Sed sed = new Sed(new Replacer() { @Override public String process(String line) { return macro.process(line); } }, f); sed.replace(pattern, replacement); return sed.doIt() > 0; }
boolean replace(File f, String pattern, String replacement) throws IOException { final Macro macro = getReplacer(); Sed sed = new Sed(new Replacer() { public String process(String line) { return macro.process(line); } }, f); sed.replace(pattern, replacement); return sed.doIt() > 0; }
boolean replace(File f, String pattern, String replacement) throws IOException { final Macro macro = getReplacer(); Sed sed = new Sed(new Replacer() { public String process(String line) { return macro.process(line); } }, f); sed.replace(pattern, replacement); return sed.doIt() > 0; }
boolean replace(File f, String pattern, String replacement) throws IOException { final Macro macro = getReplacer(); Sed sed = new Sed(new Replacer() { @Override public String process(String line) { return macro.process(line); } }, f); sed.replace(pattern, replacement); return sed.doIt() > 0; }
boolean replace(File f, String pattern, String replacement) throws IOException { final Macro macro = getReplacer(); Sed sed = new Sed(new Replacer() { public String process(String line) { return macro.process(line); } }, f); sed.replace(pattern, replacement); return sed.doIt() > 0; }
@Description("Generate autocompletion file for bash") public void _bash(Options options) throws Exception { File tmp = File.createTempFile("bnd-completion", ".tmp"); tmp.deleteOnExit(); try { IO.copy(getClass().getResource("bnd-completion.bash"), tmp); Sed sed = new Sed(tmp); sed.setBackup(false); Reporter r = new ReporterAdapter(); CommandLine c = new CommandLine(r); Map<String,Method> commands = c.getCommands(this); StringBuilder sb = new StringBuilder(); for (String commandName : commands.keySet()) { sb.append(" " + commandName); } sb.append(" help"); sed.replace("%listCommands%", sb.toString().substring(1)); sed.doIt(); IO.copy(tmp, out); } finally { tmp.delete(); } }
void updatePackageInfoJavaFile(String packageName, final Version newVersion) throws Exception { File file = getPackageInfoJavaFile(packageName); if (!file.exists()) { return; } // If package/classes are copied into the bundle through Private-Package // etc, there will be no source if (!file.getParentFile().exists()) { return; } Version oldVersion = getPackageInfo(packageName); if (newVersion.compareTo(oldVersion) == 0) { return; } Sed sed = new Sed(new Replacer() { public String process(String line) { Matcher m = VERSION_ANNOTATION.matcher(line); if (m.find()) { return line.substring(0, m.start(3)) + newVersion.toString() + line.substring(m.end(3)); } return line; } }, file); sed.replace(VERSION_ANNOTATION.pattern(), "$0"); sed.setBackup(false); sed.doIt(); }
void updatePackageInfoJavaFile(String packageName, final Version newVersion) throws Exception { File file = getPackageInfoJavaFile(packageName); if (!file.exists()) { return; } // If package/classes are copied into the bundle through Private-Package // etc, there will be no source if (!file.getParentFile().exists()) { return; } Version oldVersion = getPackageInfo(packageName); if (newVersion.compareTo(oldVersion) == 0) { return; } Sed sed = new Sed(new Replacer() { public String process(String line) { Matcher m = VERSION_ANNOTATION.matcher(line); if (m.find()) { return line.substring(0, m.start(3)) + newVersion.toString() + line.substring(m.end(3)); } return line; } }, file); sed.replace(VERSION_ANNOTATION.pattern(), "$0"); sed.setBackup(false); sed.doIt(); }
void updatePackageInfoJavaFile(String packageName, final Version newVersion) throws Exception { File file = getPackageInfoJavaFile(packageName); if (!file.exists()) { return; } // If package/classes are copied into the bundle through Private-Package // etc, there will be no source if (!file.getParentFile().exists()) { return; } Version oldVersion = getPackageInfo(packageName); if (newVersion.compareTo(oldVersion) == 0) { return; } Sed sed = new Sed(new Replacer() { public String process(String line) { Matcher m = VERSION_ANNOTATION.matcher(line); if (m.find()) { return line.substring(0, m.start(3)) + newVersion.toString() + line.substring(m.end(3)); } return line; } }, file); sed.replace(VERSION_ANNOTATION.pattern(), "$0"); sed.setBackup(false); sed.doIt(); }
public void bump(String mask) throws IOException { Sed sed = new Sed(getReplacer(), getPropertiesFile()); sed.replace("(Bundle-Version\\s*(:|=)\\s*)(([0-9]+(\\.[0-9]+(\\.[0-9]+)?)?))", "$1${version;" + mask + ";$3}"); sed.doIt(); forceRefresh(); }
public void bump(String mask) throws IOException { Sed sed = new Sed(getReplacer(), getPropertiesFile()); sed .replace( "(Bundle-Version\\s*(:|=)\\s*)(([0-9]+(\\.[0-9]+(\\.[0-9]+)?)?))", "$1${version;" + mask + ";$3}"); sed.doIt(); refresh(); }