ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stuart Halloway" <...@develop.com>
Subject Property propagation?
Date Tue, 24 Oct 2000 17:13:35 GMT
According to the docs, properties are propagated by the "ant" task, and
override any "property" task settings.  I am not finding this to be the
case, e.g.

<project name="test" default="all" basedir=".">
  <target name="clean">
    <property name="myprop" value="other" />
    <echo message="clean ran, myprop=${myprop}"/>
  </target>
  <target name="compile">
    <echo message="compile ran, myprop=${myprop}"/>
  </target>
  <target name="all">
    <echo message="all ran, myprop=${myprop}"/>
    <ant antfile="test.xml" target="clean"/>
    <ant antfile="test.xml" target="compile"/>
  </target>
</project>

The idea of this project is that "all" depends on "clean" followed by
"compile," BUT "compile" does not depend on "clean."  To make this work, I
execute "clean" and "compile" as "ant" tasks under the "all" target.

Properties passed on the command line correctly propagate to the ant
sub-tasks, but then the "property" task is able to change them.  So, with
the command line

	ant -buildfile=test.xml -Dmyprop=foo all

the "all" task correctly uses the value "foo" but the "clean" task uses the
value "other."  As a workaround, I can pass the properties explicitly, like
this:

<ant antfile="test.xml" target="clean">
  <property name="myprop" value="${myprop}" />
</ant>

Is this an ant bug, a stu bug, or a doc error?  :-)

Stuart Halloway
DevelopMentor
http://staff.develop.com/halloway


Mime
View raw message