C.39 IniFileTask

The IniFileTask is inspired by the Ant-Contrib IniFile and can be used to build and edit .ini files. Unlike the Ant equivalent, it can also read values from different sections of an .ini file and set the retrieved values to specified properties.

Table C.45: Attributes

NameTypeDescriptionDefaultRequired
deststringThe name of the .ini file to write to. If not specified, the source file will be modified instead.noneNo
haltOnErrorbooleanShould the build fail when problems occur?falseNo
sourcestringThe name of the .ini file to read from. If not specified, the dest file will be used instead.noneNo

C.39.1 Supported Nested Tags

  • get

    Use to read a value from a specific key and section of an .ini file

    Table C.46: Attributes

    NameTypeDescriptionDefaultRequired
    defaultStringValue to return if section, property or value are not setn/aNo
    sectionStringName of the section.n/aYes
    propertyStringName of the key, in the specified section, to readn/aYes
    outputpropertyStringName of the property to set the value ton/aYes

  • remove

    Use to remove either a specific key or section from an .ini file

    Table C.47: Attributes

    NameTypeDescriptionDefaultRequired
    sectionStringName of the section.n/aYes
    propertyStringName of the key to remove. If not specified the entire section is removed.n/aNo

  • set

    Use to set a key in a section to a specific value

    Table C.48: Attributes

    NameTypeDescriptionDefaultRequired
    sectionStringName of the section.n/aYes
    propertyStringName of the key/property.n/aYes
    operationStringThe operation to perform on the existing value, which must be numeric. Possible values are "+" and "-", which add and subtract 1, respectively from the existing value. If the value doesn't already exist, the set is not performed, triggering an error.n/aNo
    valueStringThe new value for the property.n/aNo, if operation is specified.

C.39.2 Example

<inifile
    haltonerror="no"
    dest="${project.basedir}/application/configs/application.ini">
    <set section="production" property="buildTimestamp" value="${DSTAMP}${TSTAMP}" />
    <set section="production" property="buildNumber" operation="+" />
    <remove section="development : staging" />
</inifile>