ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: reassigning perperty values?
Date Fri, 27 Oct 2000 19:32:10 GMT
Some clarification (I hope):

<ant> takes nested <property>'s; <antcall> takes nested <param>'s.
<ant>
needs a build-file "argument" (ie., an "antfile" attribute specified),
<antcall> looks for the specified target in the current build-file. You
can specify the current build-file in an <ant> if you want, and get the
same behaviour, property-wise, as using <antcall>, but <antcall> is a
shorter way to get there (and I think there might be less overhead?).

If you <ant> to a target in another build-file, and don't specify a
<property>, you will get the value that property is set to by default in
the calling build-file. If you specify a property in the <ant>, the value
of that property is set not only in the build-file you called with <ant>
(overriding any value it may be set to by default in the called
build-file), but is also set to that value in any build-files that are
called from that one (overriding their default) -- unless the <ant> calls
to those build-files also include a <property> to set the value to
something else:

[binky] ant -f test.xml printa ; ant -f test1.xml printa ; ant -f
test2.xml
Buildfile: test.xml
printa:
 In test.xml, target "printa": a is apple #this is the default in test.xml

Calling test1.xml, target "printa"...
printa:
 In test1.xml, target "printa": a is apple #test1's default is overridden

Calling test2.xml, target "printa"...
printa:
 In test2.xml, target "printa": a is apple #test2's default is overridden

BUILD SUCCESSFUL
Total time: 1 second
Buildfile: test1.xml
printa:
 In test1.xml, target "printa": a is acrobat  #test1.xml's default

Calling test2.xml, target "printa"...
printa:
 In test2.xml, target "printa": a is acrobat  #test2's default overridden

BUILD SUCCESSFUL
Total time: 0 seconds
Buildfile: test2.xml
printa:
 In test2.xml, target "printa": a is abalone  #test2.xml's default

BUILD SUCCESSFUL
Total time: 0 seconds

[binky] ant -f test.xml printb
Buildfile: test.xml
printb:
 In test.xml, target "printb": a is apple       #test.xml's default
Using antcall to re-set "a" to apricot...
localset:
 In test.xml, local override is: a is apricot   #local override w/antcall
 Returned from antcall, in "printb": a is apple #reverts to default

BUILD SUCCESSFUL
Total time: 1 second

[binky] ant -f test.xml testsub
Buildfile: test.xml
testsub:
Calling "localset" with antcall to set "a" to apricot...
localset:
 In test.xml, local override is: a is apricot

Calling "localset" with ant to set "a" to alphabet...
localset:
 In test.xml, local override is: a is alphabet

Calling test1.xml, target "printa"...      #test1's default will be
printa:                                    #overridden by test's default,
 In test1.xml, target "printa": a is apple #which is not affected
                                           #by <ant> and <antcall> above
Calling test2.xml, target "printa"...
printa:
 In test2.xml, target "printa": a is apple  #ditto

Calling test1.xml, target "localset", setting "a" to apricot...
localset:
 In test1.xml, target "localset": a is apricot

Calling test2.xml, target "localset", w/o property-set override...
localset:
 In test2.xml, target "localset": a is apricot #from test1's override

Calling test.xml, target "printa"
printa:
 In test.xml, target "printa": a is apricot    #ditto

Calling test1.xml, target "printa"...
printa:
 In test1.xml, target "printa": a is apricot   #still in effect

Calling test2.xml, target "printa"...
printa:
 In test2.xml, target "printa": a is apricot   #ditto

Calling test2.xml, target "localset", with "a" set to almonds...
localset:
 In test2.xml, target "localset": a is almonds

Calling test.xml, target "printa"
printa:
 In test.xml, target "printa": a is almonds    #test2's override

Calling test1.xml, target "printa"...
printa:
 In test1.xml, target "printa": a is almonds   #ditto

Calling test2.xml, target "printa"...
printa:
 In test2.xml, target "printa": a is almonds   #still in effect


BTW: It -is- possible to get yourself into an infinite loop in Ant -- if
you use <ant> to call a target in another build-file, and that target
includes an <ant> to the target in the build-file that has the <ant> call
to this target... :)

I hope this help, rather than adds to the confusion,
Diane

--- Gottfried Szing <goofy@yasd.dhs.org> wrote:
> On Fri, 27 Oct 2000 glennm@ca.ibm.com wrote:
> 
> > 
> > 
> > Use
> > 
> > <antcall target="compile_sources">
> >   <property name="SOURCES" value="x1.java,x2.java" />
> > </antcall>
> > 
> > That should get you the results you want.  The <antcall> task is just
> a
> > short form of the <ant> task, which lets you specify nested
> <property>.
> 
> thats not really the same:
> - i cannot call an build script in an different directory. of
> course via a sub target which calls an ant task. 
> 
> - the parent directory or better the build.xml which starts the
> sub project must know the properties needed in the sub project.
> so this would bring many problems! not really easy to maintain.
> 
> -- 
> cu, goofy
> 
> To predict the future, you must know the past. -Pat Artis
>     --> http://yasd.dhs.org/ ICQ: 34550587
> 


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



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

Mime
View raw message