LoadResource

Since Apache Ant 1.7

Description

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.

Parameters

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 is 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 is false

The LoadResource task supports nested FilterChains.

Examples

Load the entry point of Ant's homepage into property homepage; an <echo> can print this.

<loadresource property="homepage">
    <url url="https://ant.apache.org/index.html"/>
</loadresource>

For more examples see the loadfile task.