Eugeny89
Eugeny89

Reputation: 3731

"global var" in ant

I'm calling one target (e.g target) from other targets (e.g. first, second). Is there a way to define a property (or whatever) in target in such a way that it could be used in first and second. Please don't advise me to pass a variable as a parameter into first and second

Upvotes: 2

Views: 4073

Answers (2)

Mikael Vandmo
Mikael Vandmo

Reputation: 945

In latest versions of ant you can use the "local" task to declare a variable as local.

Otherwise properties are always global.

Upvotes: 1

Lesmana
Lesmana

Reputation: 27043

Every "variable" (property) ever set in ant is always "global"

<project name="foo" default="first">

  <target name="first" depends="target">
    <echo message="${foo}"/>
  </target>

  <target name="second" depends="target">
    <echo message="${foo}"/>
  </target>

  <target name="target">
    <property name="foo" value="bar"/>
  </target>

</project>

Upvotes: 1

Related Questions