ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: antcall and immutable properties ... Normal ?
Date Tue, 09 Dec 2003 07:59:13 GMT
<antcall> opens a new scope for properties. Properties which are set
in the called target are not available in the calling target. Therefore
this should work:

<target name="A">
    <antcall target="B"><param name="filename" value="file1"/></antcall>
    <antcall target="B"><param name="filename" value="file2"/></antcall>
</target>

<target name="B.check">
    <available property="filename_exist" file="${filename}"/>
</target>

<target name="B" depends="B.check" if="filename_exist">
    <echo>filename ${filename} exist</echo>
</target>

That should work without any external task library and with Ant 1.5.



For easier scripting AntContrib [1] could be something for you:

<target name="A">
    <foreach param="filename" list="file1,file2" target="B"/>
</target>

<target name="B.check"/>   <!-- same as above -->
<target name="B"/>


And with Ant 1.6 [2] maybe the *def family [3,4,5] would help.


Jan

[1] http://sourceforge.net/projects/ant-contrib/
[2] http://cvs.apache.org/dist/ant/v1.6beta3/
[3] http://ant.apache.org/manual-1.6beta/CoreTasks/macrodef.html
[4] http://ant.apache.org/manual-1.6beta/OptionalTasks/scriptdef.html
[5] http://ant.apache.org/manual-1.6beta/CoreTasks/presetdef.html





> -----Original Message-----
> From: Noel Sebastien (BIL) [mailto:Sebastien.Noel@dexia-bil.com]
> Sent: Monday, December 08, 2003 3:38 PM
> To: user@ant.apache.org
> Subject: antcall and immutable properties ... Normal ?
> 
> 
> Hi everyone,
> 
> I am using Ant 1.5. I need a functionality to start a task 
> (via antcall) only if a variable condition is true.
> This task should be called multiple times and that is the 
> problem because the "if" attribute of "antcall" only supports 
> PROPERTIES (that are immutable !!!).
> 
> Here is an example where i would like to use a file 
> (deletion, touch and so on) if it already exists and to do 
> nothing if it does not exist :
> 
> <task          A>
> 	<antCall target=B><param name="filename" 
> value="file1"/></antCall>
> 	<antCall target=B><param name="filename" 
> value="file2"/></antCall>
> </task>
> 
> <task          B        if="$filename_exist">         <!-- 
> <<<<< where and how to set "filename_exist" property which 
> may vary ?? -->
> 	<!-- actions using parameters $filename --> 
> </task>
> 
> 
> Maybe there is another task (or another easier way) to do 
> this, tell me it then...
> Thank you in advance,
> 
> S├ębastien NOEL 
> 
> 
> 
> ---------------------
> An electronic message is not binding on its sender.  
> Any message referring to a binding engagement must be 
> confirmed in writing and duly signed.
> ---------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message