Setting Properties in an Ant Script

You can configure properties in your Ant scripts at both the project and target levels. There are two ways of adding Ant properties to your Ant script:

To add a property as an XML tag in your Ant script:

  1. Right-click the script's Ant project node.
  2. Choose Add and choose property. A property with the default name and value is inserted at the end of the project. A task node (task node icon) for the property appears in the Explorer.

To define your Ant script's properties in a separate properties file:

  1. Right-click the Ant project node in the Explorer and choose Properties. If you want to set a separate properties file for a target, right-click the target node and choose Properties.
  2. Click the ellipsis button in Project Properties or Target Properties. The Create Properties File wizard opens.
  3. Change name for the properties file name if necessary, or click Next to accept the default name. The IDE automatically appends the file name with the .ant.properties suffix.
  4. Type your properties in the text area. Form properties using the same syntax as regular properties files (key=value) without quotation marks. Click Finish.

    The properties file is created in the same directory as your Ant project and a <property file="filename"> tag is added to your Ant script. You can edit the properties by going to the property sheet for the Ant project or target and clicking Project Properties or Target Properties. Alternatively, you can double-click the properties file to work with it in the properties pane of Source Editor.

You can edit the contents of a properties file in either of the following ways:

To change the properties file referenced by your Ant script:

  1. Right-click the project or target's node in the Explorer and choose Properties.
  2. Select a different properties file from the Switch Properties File combo box. This combo box lists all of the .ant.properties files in the present directory.
    Alternatively, you can change the value of the <property file="..."/> tag directly in your script, or select the property task node and change the file attribute in its property sheet.
tip

In addition to your user-defined properties, the IDE also includes a set of global properties that are passed to Ant each time you run an Ant script. To view these properties, choose Tools and choosing Options and expand the Building node. Then select Ant Properties and click the ellipsis button in the Properties setting.

See also

Ant Project Files
Executing a Target
Modifying a Properties File
Configuring Ant Settings


Legal Notices