AndreaNobili
AndreaNobili

Reputation: 43077

Can I declare the property value in an ant target and use this value into another target?

I am pretty new in Ant and I have the following doubt:

If I declare a property in a specific target, for example this:

<target name="initUnixPath" if="unix">
    <echo message="initUnixPath: SETTING UNIX PATH" />
    <property name="path">/usr/share/XCloud/appl/lib/</property>
</target>

In a second time (in another target) can I use the path named property and initialized in the initUnixPath target?

Tnx

Andrea

Upvotes: 0

Views: 56

Answers (1)

Reji
Reji

Reputation: 3516

you can make the second target "depends" on the first target that has the property defined. Then use the property in the second target.

    <project default="child">
      <target name="child" depends="parent">
        <property name="firstname" value="Reji"/>
        <echo>${firstname}</echo>
        <echo>${lastname}</echo>
      </target>
      <target name="parent">
        <property name="lastname" value="Nair"/>
      </target>
    </project>

Upvotes: 1

Related Questions