Try:
ant t1 t2
with build.xml:
<project default="t1-t2">
<target name="init">
<property name="init" value="true"/>
</target>
<target name="t1" depends="init">
<property name="t1" value="true"/>
</target>
<target name="t2" depends="init">
<echo message="t1 = ${t1}"/>
<echo message="init = ${init}"/>
</target>
<target name="t1-t2" depends="t1, t2" />
</project>
and compare it to:
ant t1-t2.
In both cases, the property t1 is visible to target t2, but the fact that
init is called twice when both t1 and t2 are on the command line tells me a
different Project (like for <antcall>) is used, but different projects
should not see each others properties (Project for t2 is not a child of
Project for t1, it should be a sibling).
What I would actually prefer is 'ant t1 t2' work the same as 'ant t1-t2',
and always have init called only once! It makes no sense to me to have
<init> execute twice when 2 targets are on the ant command line!!! --DD
D:\org_apache\antx>..\jakarta-ant15\dist\bin\ant
Buildfile: build.xml
init:
t1:
t2:
[echo] t1 = true
[echo] init = true
t1-t2:
BUILD SUCCESSFUL
Total time: 2 seconds
D:\org_apache\antx>..\jakarta-ant15\dist\bin\ant t1 t2
Buildfile: build.xml
init:
t1:
init:
t2:
[echo] t1 = true
[echo] init = true
BUILD SUCCESSFUL
Total time: 1 second
D:\org_apache\antx>
-----Original Message-----
From: Nicola Ken Barozzi [mailto:[EMAIL PROTECTED]
Sent: Saturday, July 20, 2002 2:34 PM
To: Ant Developers List
Subject: Re: <init>/<finally> and top-level tasks (was RE: Problems with
<impo rt>)
> Question #3:
> Why is it that running:
>
> ant -builldfile antx build doSomething
>
> runs init twice (both targets depends on it), but properties set by the
> first target are visible in the second target. It looks like each target
is
> executed in its own Project, but the fact that the second sees properties
> set by the first contradicts that!!!
:-?
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>