ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <>
Subject Re: Clarification on definition of "reference"
Date Thu, 04 Jun 2009 19:29:16 GMT
The easiest way to think of this is a reference is as a pointer to a
resource in Ant. An Ant resource merely some sort of Ant object such as a
property, a set of files, a path, a fileset, taskdefs, etc.
(Yes, a property is a resource, and could have a reference point to it:

**<!--Property Set -->
<property name="" value="Hello World!"/>

<!-- Setting a reference to point to the property -->

<!-- Setting a new property from your reference -->
<property name="" refid=""/>
<echo message="${}"/>
* )*

References allow you to define them in one place, but use them elsewhere.
The most common example is a classpath. It is quite common to define the
classpath in one place in Ant, and then use that reference when you actually
run the <java>, <junit>, or <javac> tasks.

When you define a reference, you use the parameter "id=". When you use the
reference, you use the "refid=".

For some reason, references and properties are treated differently in these

   - *Properties*
      - By default, are inherited
      - Will override existing properties if inherited
      - Inheriting is done via *inheritAll* parameter.
      - If specified as a nested element, will override existing properties.
      - *References*
      - By default are *not* inherited
      - Will *not* override existing reference definitions if inherited.
      - Inheriting is done via *inheritRefs* parameter.
      - If specified as a nested element, will override existing properties.

Personally, I set both "inheritAll" and InheritRefs to false and then
specify exactly which properties and references I want as nested elements.
That way, I know exactly what is being passed and how it will affect the
called target.*

On Tue, Jun 2, 2009 at 3:10 PM, Jim Garrison <> wrote:

> The ANT docs use the term "reference" in a way that, at least to me, is a
> little confusing.  The term "reference" seems to mean both the act of
> referring to an object defined elsewhere (as in "refid=...") and also the
> object being referred to.  Are the following correct?
>  1.  A "Property" is a name-value pair defined with the <property> tag, and
> its identifier is the value of the "name=..." attribute
>  2.  A "Reference" is defined by any object definition using its "id=..."
> attribute (is this aka a "Type"?)
>  3.  By default (without inheritRefs and nested reference tags), <ant> and
> <antcall> establish a new scope for reference objects. That is:
>    *   At the point in the calling buildfile where the sub-ant is invoked,
> there exists a set of visible reference objects
>    *   In the called buildfile, that set of reference objects is NOT
> visible
>  4.  Reference objects can be made visible inside the sub-build using
> inheritRefs="true", or by providing explicit nested <reference> tags inside
> the <ant> or <antcall> that invoked the sub-build.

David Weintraub

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message