ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gle...@ca.ibm.com
Subject Re: Property propagation?
Date Tue, 24 Oct 2000 18:44:22 GMT


Err... a cleaner way to do what you want is

<project name="test" defalt="all">
  <target name="all" depends="clean,compile">
    <echo message="Build complete!" />
  </target>

  <target name="clean">
    <delete dir="${build.dir}" />
  </target>

  <target name="compile">
    <javac ... />
  </target>
</project>

If you do it with <ant> calls, you a simply doubling your memory
requirements, and probably the time as well.  And Diane is right about how
to use the nested <property> tag of the <ant> task.  Be aware that in Ant
1.2 the resolution of property values occurs at runtime, rather than parse
time.

Glenn McAllister
Software Developer. IBM Toronto Lab, (416) 448-3805
"An approximate answer to the right question is better than the
right answer to the wrong question." - John W. Tukey


Please respond to ant-user@jakarta.apache.org

To:   ant-user@jakarta.apache.org
cc:
Subject:  Re: Property propagation?

I might be too sleep-deprived to be answering this correctly, but I think
you should be including a nested <property> in your <ant> calls, in order
to pass to the "clean" target's "myprop" the value you want. Ie:
<ant antfile="test.xml" target="clean">
  <property name="myprop" value="${myprop}"/>
</ant>

Diane

--- Stuart Halloway <stu@develop.com> wrote:
> 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
>


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Messenger - Talk while you surf!  It's FREE.
http://im.yahoo.com/




Mime
View raw message