ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck.Irv...@mail.sprint.com
Subject easier way to conditionally copy file? / write my own task?
Date Fri, 12 Oct 2001 16:47:28 GMT
Conceptually what I want to do is simple. If file:
	deploy/constants.properties
doesn't exist, create it by copying:
	src/constants-default.properties -> deploy/constants.properties
And, actually I need to do this for three different environment: local, 
dev, and test.

With the help of those on this mailing list, I've come up with the set 
of target below. This just seems more elaborate than it ought to be. 
Further, I now need to do essentially the same thing with another 
properties file, which with my current level of knowledge would have me 
duplicating each of the targets below. 

My question is, is there a better way to do this without writing a 
custom task? I'm guessing not and that I need to write my first custom 
task. 

Thanks for your help.

(PS: would the functionality above be a good candidate for extending 
the built in "copy" task?)

Chuck

 <target name="localCompile" depends="...,copyLocalConstants">
  ...
 </target>

 <target name="isLocalConstantsAvailable">
   <available
      file="${tomcat.fms.classes}/com/sprint/fms/constants.properties"
      property="local.constants.available"/>
 </target>
 
 <target name="copyLocalConstants"
         unless="local.constants.available"
         depends="isLocalConstantsAvailable">
   <copy
      file="src/com/sprint/fms/constants-default.properties"
      
tofile="${tomcat.fms.classes}/com/sprint/fms/constants.properties"/>
 </target>

 <target name="isDevConstantsAvailable">
   <available
      file="${was.fms.dev.home}/classes/resource/constants.properties"
      property="dev.constants.available"/>
 </target>

 <target name="isTestConstantsAvailable">
   <available
      file="${was.fms.test.home}/classes/resource/constants.properties"
      property="dev.constants.available"/>
 </target>
 
 <target name="copyDevConstants" depends="isDevConstantsAvailable"
   unless="dev.constants.available">
   <copy
      file="src/com/sprint/fms/constants-default.properties"
      
tofile="${was.fms.dev.home}/classes/resource/com/sprint/fms/constants.pr
operties"/>
 </target>
 
 <target name="copyTestConstants" depends="isTestConstantsAvailable"
   unless="test.constants.available">
   <copy
      file="src/com/sprint/com/constants-default.properties"
      
tofile="${was.fms.test.home}/classes/resource/com/sprint/fms/constants.p
roperties"/>
 </target>


Mime
View raw message