Methods Summary |
---|
public void | execute()execute patch
if (!havePatchfile) {
throw new BuildException("patchfile argument is required",
getLocation());
}
Commandline toExecute = (Commandline) cmd.clone();
toExecute.setExecutable("patch");
if (originalFile != null) {
toExecute.createArgument().setFile(originalFile);
}
Execute exe = new Execute(new LogStreamHandler(this, Project.MSG_INFO,
Project.MSG_WARN),
null);
exe.setCommandline(toExecute.getCommandline());
if (directory != null) {
if (directory.exists() && directory.isDirectory()) {
exe.setWorkingDirectory(directory);
} else if (!directory.isDirectory()) {
throw new BuildException(directory + " is not a directory.",
getLocation());
} else {
throw new BuildException("directory " + directory
+ " doesn\'t exist", getLocation());
}
} else {
exe.setWorkingDirectory(getProject().getBaseDir());
}
log(toExecute.describeCommand(), Project.MSG_VERBOSE);
try {
exe.execute();
} catch (IOException e) {
throw new BuildException(e, getLocation());
}
|
public void | setBackups(boolean backups)flag to create backups; optional, default=false
if (backups) {
cmd.createArgument().setValue("-b");
}
|
public void | setDestfile(java.io.File file)The name of a file to send the output to, instead of patching
the file(s) in place; optional.
if (file != null) {
cmd.createArgument().setValue("-o");
cmd.createArgument().setFile(file);
}
|
public void | setDir(java.io.File directory)The directory to run the patch command in, defaults to the
project's base directory.
this.directory = directory;
|
public void | setIgnorewhitespace(boolean ignore)flag to ignore whitespace differences; default=false
if (ignore) {
cmd.createArgument().setValue("-l");
}
|
public void | setOriginalfile(java.io.File file)The file to patch; optional if it can be inferred from
the diff file
originalFile = file;
|
public void | setPatchfile(java.io.File file)The file containing the diff output; required.
if (!file.exists()) {
throw new BuildException("patchfile " + file + " doesn\'t exist",
getLocation());
}
cmd.createArgument().setValue("-i");
cmd.createArgument().setFile(file);
havePatchfile = true;
|
public void | setQuiet(boolean q)Work silently unless an error occurs; optional, default=false
if (q) {
cmd.createArgument().setValue("-s");
}
|
public void | setReverse(boolean r)Assume patch was created with old and new files swapped; optional,
default=false
if (r) {
cmd.createArgument().setValue("-R");
}
|
public void | setStrip(int num)Strip the smallest prefix containing num leading slashes
from filenames.
patch's -p option.
if (num < 0) {
throw new BuildException("strip has to be >= 0", getLocation());
}
cmd.createArgument().setValue("-p" + num);
|