public class FileProperty extends org.apache.tools.ant.Task
If the specified file exists, this task sets the properties
<name>
, <name>.name
,
<name>.wildcard
,
in the project. Properties are case sensitive.
Normally, this task is used with files whose names contain a variable portion, the matching of which is facilitated by a PatternSet which allows '*' and '?' wildcarding (see Ant's documentation).
If multiple files are found which match the file pattern, a BuildException is thrown.
Attribute | Description | Required |
name | The name (handle) of the property. | Yes |
dir | The directory containing the file. If not set, it defaults to the current directory. | Yes |
file | The name of the file (may contain wildcards). If not set, a directory is searched for in place of a file. | |
if | Only execute if a property of the given name exists in the current project. | No |
unless | Only execute if a property of the given name doesn't exist in the current project. | No |
The if
and unless
attributes make the
execution conditional -both probe for the named property being defined.
The if
tests for the property being defined, the
unless
for a property being undefined.
execute := defined(ifProperty) && !defined(unlessProperty)
${lib.dir}
contained the file commons-net-20040324.jar
<fileproperty name='commons_net' dir='${lib.dir}' file='commons-net-*.jar' />would set the
commons_net
property to ${lib.dir}/commons-net-20040324.jar
,
the commons_net.name
property to commons-net-20040324.jar
,
the commons_net.wildcard
property to 20040324
Constructor and Description |
---|
FileProperty() |
Modifier and Type | Method and Description |
---|---|
void |
execute() |
void |
setDebug(String inValue) |
void |
setDir(File dir) |
void |
setFile(String file) |
void |
setIf(String inPropertyName)
Only execute if a property of the given name exists in the current project
|
void |
setName(String name) |
void |
setUnless(String inPropertyName)
Only execute if a property of the given name does not exist in the current project
|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
public FileProperty()
public void setDir(File dir) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
public void setDebug(String inValue) throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildException
public void setIf(String inPropertyName)
inPropertyName
- property namepublic void setUnless(String inPropertyName)
inPropertyName
- property namepublic void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException