Since Apache Ant 1.7


Load a text resource into a single property. Unless an encoding is specified, the encoding of the current locale is used. Resources to load are specified as nested resource elements or single element resource collections. If the resource content is empty (maybe after processing a filterchain) the property is not set.

Since properties are immutable, the task will not change the value of an existing property.


Attribute Description Required
property property to save to Yes
encoding encoding to use when loading the resource No
failonerror Whether to halt the build on failure No, default "true"
quiet Do not display a diagnostic message (unless Ant has been invoked with the -verbose or -debug switches) or modify the exit status to reflect an error. Setting this to "true" implies setting failonerror to "false". No, default "false"

The LoadResource task supports nested FilterChains.


<loadresource property="homepage">
  <url url="http://ant.apache.org/index.html"/>
Load the entry point of Ant's homepage into property "homepage"; an <echo> can print this.

For more examples see the loadfile task.