ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck.Irv...@mail.sprint.com
Subject RE: easier way to conditionally copy file? / write my own task?
Date Fri, 12 Oct 2001 20:07:20 GMT
Diane,

Before I posted my question, I did a scan of both the built-in and 
optional tasks, but somehow I missed "antcall". Looks to be just what I 
need. Thanks!!

BTW. Ant is great! Before my current project we used "make" as our 
build system. It just never felt like a good fit for Java development. 
For our current project we are using Ant, and I never want to use make 
again. 

Another BTW - In the "why" section of the user documentation, the HUGE 
number of built-in (and optional) tasks ought to be mentioned. I'm 
amazed by easy things are, event when I'm still on the learning curve.

Thanks again.

Chuck

> -----Original Message-----
> From: holtdl [mailto:holtdl@yahoo.com]
> Sent: Friday, October 12, 2001 2:49 PM
> To: ant-user
> Cc: holtdl
> Subject: Re: easier way to conditionally copy file? / write 
> my own task?
> 
> 
> As a general rule-of-thumb, when I find myself creating 
> targets that are
> essentially doing the same thing, I probably want to start 
> thinking about
> creating a target to <antcall> to. For example, in your case 
> (btw: I've
> set the dirs into properties, but you don't really have to do 
> that -- I
> just find it easier to deal with):
> 
>   <property name="tomcat.fms.classes" value="foodir"/>
>   <property name="was.fms.dev.home" value="foodir"/>
>   <property name="was.fms.test.home" value="foodir"/>
>   <property name="tomcat.classes"
>             value="${tomcat.fms.classes}/com/sprint/fms"/>
>   <property name="dev.home"
>             
> value="${was.fms.dev.home}/classes/resource/com/sprint/fms"/>
>   <property name="test.home"
>             value="${was.fms.test.home}/classes/resource"/>
>   <property name="sprint.fms" value="src/com/sprint/fms"/>
>   <property name="sprint.com" value="src/com/sprint/com"/>
> 
>   <target name="copyFiles">
>     <antcall target="doCopy">
>       <param name="dir" value="${sprint.fms}"/>
>       <param name="todir" value="${tomcat.classes}"/>
>     </antcall>
>     <antcall target="doCopy">
>       <param name="dir" value="${sprint.fms}"/>
>       <param name="todir" value="${dev.home}"/>
>     </antcall>
>     <antcall target="doCopy">
>       <param name="dir" value="${sprint.com}"/>
>       <param name="todir" value="${test.home}"/>
>     </antcall>
>   </target>
> 
>   <target name="doCopy" depends="checkFile" 
> unless="constantsAvailable">
>     <copy file="${dir}/constants-defaults.properties"
>           tofile="${todir}/constants.properties"/>
>   </target>
> 
>   <target name="checkFile">
>     <condition property="constantsAvailable">
>       <available file="${todir}/constants.properties"/>
>     </condition>
>   </target>
> 
> If you need to add additional files to check for, just add an 
> <antcall>
> for them. If it turns out the filenames won't always be the 
> same, add a
> (eg.) "file" parameter to pass as well (ie., changing things like
> file="${dir}/constants-defaults.properties" to file="${dir}/${file}").
> 
> Diane
> 
> 
> =====
> (holtdl@yahoo.com)
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
> 


Mime
View raw message