ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harkness, David" <DHarkn...@sonypictures.com>
Subject RE: How to make generic rules
Date Mon, 04 Aug 2003 06:18:02 GMT
Also, from the original poster's question, it seems more that they
wanted to set default attributes for tasks. For example:

  <default task="copy" attribute="overwrite" value="true"/>
  <default task="jar" attribute="compress" value="true"/>

These would make it such that *not* specifying "overwrite" for <copy>
would overwrite the files, and *not* specifying "compress" for <jar>
would compress the JAR. I don't believe there is any way to change the
default attribute settings for tasks, but that would be kinda cool.

Of course, you can do the same by setting a property

  <property name="default.jar.compress" value="true"/>

and then specifying that property in every <jar> task, but I think
that's what the poster was trying to avoid in the first place. At least
this buys you the ability to change the behavior build-wide by changing
one property rather than every <jar> task.

David Harkness
Sony Pictures Digital Networks
(310) 482-4756


-----Original Message-----
From: Drew Davidson [mailto:drew@ognl.org] 
Sent: Sunday, August 03, 2003 11:14 PM
To: Ant Users List
Subject: Re: How to make generic rules


North Alex wrote:

>>I'm an old makefile user. Now i'm an ant user.
>>But i haven't yet found a way to replace a powerfull
>>functionality of make: implicit rules and import of rule from 
>>a makefile in another makefile (include). In fact i need to 
>>overide some task in order to define implicit properties.
>>
>>For example i want to set the compress attribute of jar task
>>to false one time for the full build file and not to set it 
>>for each jar task.
>>
>>How can i do this?
>>    
>>
>
>One way could be to set a property and use "unless" for a target that 
>sets the properties you want.
>
>You can also call <ant> and set properties for that ant call ... or use

><antcall> :
>
>	<antcall target="update.changehistory">
>		<param name="history.version"
>value="${component.version}"/>
>	</antcall>
>
>	<antcall target="update.changehistory">
>		<param name="history.version"
>value="${baseline.version}"/>
>	</antcall>
>
>So, update.changehistory can be called from different places with 
>different values for the history.version
>  
>
But bear in mind that <ant> and <antcall> reparses the entire ant file 
each time they are used, so don't be lulled into thinking that they are 
cheap function calls.

- Drew

-- 
+---------------------------------+
< Drew Davidson | OGNL Technology >
<     Professional Open Source    >
+---------------------------------+
|  Email: drew@ognl.org          /
|    Web: http://www.ognl.org   /
|    Vox: (520) 531-1966       <
|    Fax: (520) 531-1965        \
| Mobile: (520) 405-2967         \
+---------------------------------+




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message