LoadProperties

Description

Load a file's contents as 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.

If you want to simulate property's prefix attribute, please use prefixlines filter.

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

Parameters specified as nested elements

any resource or single element resource collection

The specified resource will be used as src. Since Ant 1.7

FilterChain

classpath

for use with the resource attribute.

Examples

    <loadproperties srcFile="file.properties"/>
or
    <loadproperties>
      <file file="file.properties"/>
    </loadproperties>
Load contents of file.properties as Ant properties.
    <loadproperties srcFile="file.properties">
      <filterchain>
        <linecontains>
          <contains value="import."/>
        </linecontains>
      </filterchain>
    </loadproperties>
Read the lines that contain the string "import." from the file "file.properties" and load them as Ant properties.
    <loadproperties>
      <gzipresource>
        <url url="http://example.org/url.properties.gz"/>
      </gzipresource>
    </loadproperties>
Load contents of http://example.org/url.properties.gz, uncompress it on the fly and load the contents as Ant properties.