Save This Page
Home » apache-ant-1.7.1-src » org.apache.tools » ant » taskdefs » [javadoc | source]
org.apache.tools.ant.taskdefs
public class: Property [javadoc | source]
java.lang.Object
   org.apache.tools.ant.ProjectComponent
      org.apache.tools.ant.Task
         org.apache.tools.ant.taskdefs.Property

All Implemented Interfaces:
    Cloneable

Direct Known Subclasses:
    FileSize

Sets a property by name, or set of properties (from file or resource) in the project.

Properties are immutable: whoever sets a property first freezes it for the rest of the build; they are most definitely not variable.

There are five ways to set properties:

Although combinations of these ways are possible, only one should be used at a time. Problems might occur with the order in which properties are set, for instance.

The value part of the properties being set, might contain references to other properties. These references are resolved at the time these properties are set. This also holds for properties loaded from a property file.

Properties are case sensitive.
Field Summary
protected  String name     
protected  String value     
protected  File file     
protected  URL url     
protected  String resource     
protected  Path classpath     
protected  String env     
protected  Reference ref     
protected  String prefix     
protected  boolean userProperty     
Fields inherited from org.apache.tools.ant.Task:
target,  taskName,  taskType,  wrapper
Fields inherited from org.apache.tools.ant.ProjectComponent:
project,  location,  description
Constructor:
 public Property() 
 protected Property(boolean userProperty) 
 protected Property(boolean userProperty,
    Project fallback) 
    Constructor for Property.
    Parameters:
    userProperty - if true this is a user property
    fallback - a project to use to look for references if the reference is not in the current project
    since: Ant - 1.5
Method from org.apache.tools.ant.taskdefs.Property Summary:
addProperties,   addProperty,   createClasspath,   execute,   getClasspath,   getEnvironment,   getFile,   getName,   getPrefix,   getRefid,   getResource,   getUrl,   getValue,   loadEnvironment,   loadFile,   loadResource,   loadUrl,   setClasspath,   setClasspathRef,   setEnvironment,   setFile,   setLocation,   setName,   setPrefix,   setRefid,   setResource,   setUrl,   setUserProperty,   setValue,   toString
Methods from org.apache.tools.ant.Task:
bindToOwner,   execute,   getOwningTarget,   getRuntimeConfigurableWrapper,   getTaskName,   getTaskType,   getWrapper,   handleErrorFlush,   handleErrorOutput,   handleFlush,   handleInput,   handleOutput,   init,   isInvalid,   log,   log,   log,   log,   markInvalid,   maybeConfigure,   perform,   reconfigure,   setOwningTarget,   setRuntimeConfigurableWrapper,   setTaskName,   setTaskType
Methods from org.apache.tools.ant.ProjectComponent:
clone,   getDescription,   getLocation,   getProject,   log,   log,   setDescription,   setLocation,   setProject
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tools.ant.taskdefs.Property Detail:
 protected  void addProperties(Properties props) 
    iterate through a set of properties, resolve them then assign them
 protected  void addProperty(String n,
    String v) 
    add a name value pair to the project property set
 public Path createClasspath() 
    The classpath to use when looking up a resource.
 public  void execute() throws BuildException 
    set the property in the project to the value. if the task was give a file, resource or env attribute here is where it is loaded
 public Path getClasspath() 
    Get the classpath used when looking up a resource.
 public String getEnvironment() 
    Get the environment attribute.
 public File getFile() 
    Get the file attribute.
 public String getName() 
    Get the property name.
 public String getPrefix() 
    Get the prefix attribute.
 public Reference getRefid() 
    Get the refid attribute.
 public String getResource() 
    Get the resource attribute.
 public URL getUrl() 
    Get the url attribute.
 public String getValue() 
    Get the property value.
 protected  void loadEnvironment(String prefix) 
    load the environment values
 protected  void loadFile(File file) throws BuildException 
    load properties from a file
 protected  void loadResource(String name) 
    load properties from a resource in the current classpath
 protected  void loadUrl(URL url) throws BuildException 
    load properties from a url
 public  void setClasspath(Path classpath) 
    The classpath to use when looking up a resource.
 public  void setClasspathRef(Reference r) 
    the classpath to use when looking up a resource, given as reference to a <path> defined elsewhere
 public  void setEnvironment(String env) 
    Prefix to use when retrieving environment variables. Thus if you specify environment="myenv" you will be able to access OS-specific environment variables via property names "myenv.PATH" or "myenv.TERM".

    Note that if you supply a property name with a final "." it will not be doubled. ie environment="myenv." will still allow access of environment variables through "myenv.PATH" and "myenv.TERM". This functionality is currently only implemented on select platforms. Feel free to send patches to increase the number of platforms this functionality is supported on ;).
    Note also that properties are case sensitive, even if the environment variables on your operating system are not, e.g. it will be ${env.Path} not ${env.PATH} on Windows 2000.

 public  void setFile(File file) 
    Filename of a property file to load.
 public  void setLocation(File location) 
    Sets the property to the absolute filename of the given file. If the value of this attribute is an absolute path, it is left unchanged (with / and \ characters converted to the current platforms conventions). Otherwise it is taken as a path relative to the project's basedir and expanded.
 public  void setName(String name) 
    The name of the property to set.
 public  void setPrefix(String prefix) 
    Prefix to apply to properties loaded using file or resource. A "." is appended to the prefix if not specified.
 public  void setRefid(Reference ref) 
    Sets a reference to an Ant datatype declared elsewhere. Only yields reasonable results for references PATH like structures or properties.
 public  void setResource(String resource) 
    The resource name of a property file to load
 public  void setUrl(URL url) 
    The url from which to load properties.
 public  void setUserProperty(boolean userProperty) 
Deprecated! since - 1.5.x. This was never a supported feature and has been deprecated without replacement.

 public  void setValue(String value) 
    The value of the property.
 public String toString() 
    get the value of this property