LoadProperties

Description

Load a file's contents as Apache Ant properties. This is equivalent to <property file|resource=.../> except that it supports nested <filterchain> elements. Also if the file is missing, the build is halted with an error, rather than a warning being printed.

Note: the default value of this task's prefixValues attribute is different from the default value of the same attribute in the <property> task.

Parameters

Attribute Description Required
srcFile source file One of these or a nested resource
resource the resource name of the property file
encoding encoding to use when loading the file No
classpath the classpath to use when looking up a resource. No
classpathref the classpath to use when looking up a resource, given as reference to a <path> defined elsewhere. No
prefix Prefix to apply to loaded properties. Since Ant 1.8.1 No; default is .
prefixValues Whether to apply the prefix when expanding the right hand side of the properties. Since Ant 1.8.2 No; default is true

Parameters specified as nested elements

any resource or single element resource collection

Since Ant 1.7

The specified resource will be used as srcFile or resource.

FilterChain

classpath

for use with the resource attribute.

Examples

Load contents of file.properties as Ant properties.

<loadproperties srcFile="file.properties"/>

or

<loadproperties>
    <file file="file.properties"/>
</loadproperties>

Read the lines that contain the string import. from the file file.properties and load them as Ant properties.

<loadproperties srcFile="file.properties">
    <filterchain>
        <linecontains>
            <contains value="import."/>
        </linecontains>
    </filterchain>
</loadproperties>

Load contents of https://example.org/url.properties.gz, uncompress it on the fly and load the contents as Ant properties.

<loadproperties>
    <gzipresource>
        <url url="https://example.org/url.properties.gz"/>
    </gzipresource>
</loadproperties>