ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Resnick" <abune...@gmail.com>
Subject RE: AW: Making copy NEVER overwrite
Date Wed, 23 Mar 2005 06:30:12 GMT
I think I have the solution in my grasp (thanks to the great suggestions of
using <modified> and <present>), but I still need some help.

I've added <present> to the original copy task and <modified> to the
filtering back copy task. It now seems to only copy when I want it to: it
backs up the files without overwriting the backup if it exists, and it
copies the files back just once. 

The problem now is that it doesn't do the filtering when it copies the files
back!

This is what I have:

<copy todir="${__root}" preservelastmodified="true">
 <mapper type="glob" from="*" to="*.bak"/>
 <fileset dir="${__root}" includes="**/*.vcp" casesensitive="false">
  <present targetdir="${__root}" present="srconly">
   <mapper type="glob" from="*" to="*.bak"/>
  </present>
 </fileset>
</copy>
<copy todir="${__root}">
 <mapper type="glob" from="*.bak" to="*"/>
  <fileset dir="${__root}" includes="**/*.vcp.bak" casesensitive="false">
   <modified cache="propertyfile">
	<param name="cache.cachefile" value="${dir.scm}/cache.properties"/>
   </modified>
  </fileset>
  <filterchain>
   <tokenfilter>
    <replaceregex pattern="(.*)/YX(.*)" replace="\1\2" flags="gi"/>
    <replaceregex pattern="(.*)/FR(.*)" replace="\1\2" flags="gi"/>
   </tokenfilter>
 </filterchain>
</copy>

If I remove the <modified> and add an overwrite attribute, the filtering
works (though it recopies each time it is run). As it shown above, it
doesn't do the filtering at all.

Any suggestions?

Thanks, David

-----Original Message-----
From: Antoine Levy-Lambert [mailto:antoine@gmx.de] 
Sent: Wednesday, March 23, 2005 00:17
To: Ant Users List
Subject: Re: AW: Making copy NEVER overwrite

I would use the <present/> selector 
something like
<copy>
  <not>
    <present ..../>
  </not>
</copy>
Cheers,
Antoine
> set the read-only flag to the files?
> 
> Jan
> 
> > -----Ursprüngliche Nachricht-----
> > Von: David Resnick [mailto:abunetta@gmail.com]
> > Gesendet am: Dienstag, 22. März 2005 11:40
> > An: 'Ant Users List'
> > Betreff: Making copy NEVER overwrite
> > 
> > I am making a backup of some files which I then filter back into the
> > original. Unfortunately, because of the way the targets are 
> > set up,  this is
> > done more than once. I want the copy task to perform the 
> > backup only if the
> > backup files don't exist. Setting overwrite to false doesn't 
> > help me because
> > the second time around the original is newer than the backup.
> > 
> >  
> > 
> > Can anyone think of a way of preventing the copy target from 
> > copying if the
> > file already exists?
> > 
> >  
> > 
> > Thanks, David
> > 
> > 
> 

---------------------------------------------------------------------
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