Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class Patch

extends Task
Class Inheritance
Imports
java.io.File, .IOException, org.apache.tools.ant.BuildException, .Project, .Task, org.apache.tools.ant.types.Commandline

Patches a file by applying a 'diff' file to it; requires "patch" to be on the execution path.
Since
Ant 1.1

Field Summary

Modifier and TypeField and Description
private Commandline
private File
private boolean
failOnError

Halt on error return value from patch invocation.

private boolean
private File
private static final String
Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
execute()

Overrides org.apache.tools.ant.Task.execute.

execute patch
public void
setBackups(boolean
if true create backups
backups
)

flag to create backups; optional, default=false

public void
setDestfile(File
the file to send the output to
file
)

The name of a file to send the output to, instead of patching the file(s) in place; optional.

public void
setDir(File
the directory to run the patch command in
directory
)

The directory to run the patch command in, defaults to the project's base directory.

public void
setFailOnError(boolean
true if it should halt, otherwise false. The default is false.
value
)

If true, stop the build process if the patch command exits with an error status.

public void
setIgnorewhitespace(boolean
if true ignore whitespace differences
ignore
)

flag to ignore whitespace differences; default=false

public void
setOriginalfile(File
the file to patch
file
)

The file to patch; optional if it can be inferred from the diff file

public void
setPatchfile(File
the file containing the diff output
file
)

The file containing the diff output; required.

public void
setQuiet(boolean
if true suppress set the -s option on the patch command
q
)

Work silently unless an error occurs; optional, default=false

public void
setReverse(boolean
if true set the -R option on the patch command
r
)

Assume patch was created with old and new files swapped; optional, default=false

public void
setStrip(int
number of lines to strip
num
)

Strip the smallest prefix containing num leading slashes from filenames.

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

cmdback to summary
private Commandline cmd
directoryback to summary
private File directory
failOnErrorback to summary
private boolean failOnError

Halt on error return value from patch invocation.

havePatchfileback to summary
private boolean havePatchfile
originalFileback to summary
private File originalFile
PATCHback to summary
private static final String PATCH

Constructor Detail

Patchback to summary
public Patch()

Method Detail

executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

execute patch

Annotations
@Override
Exceptions
BuildException:
when it all goes a bit pear shaped
setBackupsback to summary
public void setBackups(boolean backups)

flag to create backups; optional, default=false

Parameters
backups:boolean

if true create backups

setDestfileback to summary
public void setDestfile(File file)

The name of a file to send the output to, instead of patching the file(s) in place; optional.

Parameters
file:File

the file to send the output to

Since
Ant 1.6
setDirback to summary
public void setDir(File directory)

The directory to run the patch command in, defaults to the project's base directory.

Parameters
directory:File

the directory to run the patch command in

Since
Ant 1.5
setFailOnErrorback to summary
public void setFailOnError(boolean value)

If true, stop the build process if the patch command exits with an error status.

Parameters
value:boolean

true if it should halt, otherwise false. The default is false.

Since
Ant 1.8.0
setIgnorewhitespaceback to summary
public void setIgnorewhitespace(boolean ignore)

flag to ignore whitespace differences; default=false

Parameters
ignore:boolean

if true ignore whitespace differences

setOriginalfileback to summary
public void setOriginalfile(File file)

The file to patch; optional if it can be inferred from the diff file

Parameters
file:File

the file to patch

setPatchfileback to summary
public void setPatchfile(File file)

The file containing the diff output; required.

Parameters
file:File

the file containing the diff output

setQuietback to summary
public void setQuiet(boolean q)

Work silently unless an error occurs; optional, default=false

Parameters
q:boolean

if true suppress set the -s option on the patch command

setReverseback to summary
public void setReverse(boolean r)

Assume patch was created with old and new files swapped; optional, default=false

Parameters
r:boolean

if true set the -R option on the patch command

setStripback to summary
public void setStrip(int num) throws BuildException

Strip the smallest prefix containing num leading slashes from filenames.

patch's -p option.

Parameters
num:int

number of lines to strip

Exceptions
BuildException:
if num is < 0, or other errors