You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Chris Velevitch <ch...@gmail.com> on 2007/06/12 09:46:22 UTC

task to 'cp -r --reply=no'

What task is the equivalent of 'cp -r --reply=no'. This command
recursively copies files and if the file exists in the destination,
skip copying that file and continue.


Chris
--
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
m: 0415 469 095
www.flashdev.org.au

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


Re: task to 'cp -r --reply=no'

Posted by Matt Benson <gu...@yahoo.com>.
--- Gilbert Rebhan <an...@schillbaer.de> wrote:

> Gilbert Rebhan wrote:
> 
> > Blank directorie are not copied, how to achieve
> that if wanted ?
> > (manual says <cop<> task is set to
> ncludeEmptyDirs="true" ?
> 
> it's simply a question of the fileset include
> pattern
> if used
> 
> includes="**/*"  =
> 
> main:
>       [echo] Files to copy =
>       [copy] Copied 1 empty directory to 1 empty
> directory under J:\copyto
> 
> 
> so if i want to include empty dirs i use the pattern
> includes="**/*" and need to exclude all the stuff i
> don't need,
> i.e. excludes="**/*.bak, *.log"
> 

Ahh... yes, my test didn't bother specifying an
includes attribute, so I defaulted to "**/*".  :)

-Matt

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



       
____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. 
http://answers.yahoo.com/dir/?link=list&sid=396545433

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


Re: task to 'cp -r --reply=no'

Posted by Gilbert Rebhan <an...@schillbaer.de>.
Gilbert Rebhan wrote:

> Blank directorie are not copied, how to achieve that if wanted ?
> (manual says <cop<> task is set to ncludeEmptyDirs="true" ?

it's simply a question of the fileset include pattern
if used

includes="**/*"  =

main:
      [echo] Files to copy =
      [copy] Copied 1 empty directory to 1 empty directory under J:\copyto


so if i want to include empty dirs i use the pattern
includes="**/*" and need to exclude all the stuff i don't need,
i.e. excludes="**/*.bak, *.log"


Regards, Gilbert

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


Re: task to 'cp -r --reply=no'

Posted by Matt Benson <gu...@yahoo.com>.
--- Gilbert Rebhan <an...@schillbaer.de> wrote:

> Hi,
> 
> Matt Benson wrote:
> > Hi Chris:
> >   Try using a <present present="srconly" ... />
> > selector with your source <fileset>.
> > 
> > HTH,
> > Matt
> 
> Nice :-)
> 
> 
> before =
> 
> J:\copyfrom\subdir1\
> J:\copyfrom\subdir1\build.xml
> J:\copyfrom\subdir2\
> J:\copyfrom\subdir2\subsub2\build.xml
> J:\copyfrom\build.xml
> 
> and
> J:\copyto is a blank directory
> 
> with =
> 
> <?xml version="1.0"?>
> 
> <project name="bla" default="main">
> 
>    <target name="init">
>      <fileset dir="J:/copyfrom" includes="**/*.xml"
> id="newfiles">
>        <present present="srconly"
> targetdir="J:/copyto"/>
>      </fileset>
>    </target>
> 
>      <target name="main" depends="init">
>      <echo>
>       Files to copy =
> ${line.separator}${toString:newfiles}
>      </echo>
> 
>      <copy todir="J:/copyto">
>        <fileset refid="newfiles"/>
>      </copy>
> 
>    </target>
> 
> </project>
> 
> first run =
> 
> Buildfile: J:\eclipse_3_2\workspace\AntTest\test.xml
> init:
> main:
>       [echo] Files to copy =
>       [echo]
>
build.xml;subdir1\build.xml;subdir2\subsub2\build.xml
>       [copy] Copying 3 files to J:\copyto
> BUILD SUCCESSFUL
> Total time: 891 milliseconds
> 
> the blank directory gets filled with meat =
> 
> J:\copyto\subdir1\
> J:\copyto\subdir1\build.xml
> J:\copyto\subdir2\
> J:\copyto\subdir2\subsub2\build.xml
> J:\copyto\build.xml
> 
> second run =
> 
> Buildfile: J:\eclipse_3_2\workspace\AntTest\test.xml
> init:
> main:
>       [echo] Files to copy =
> BUILD SUCCESSFUL
> Total time: 516 milliseconds
> 
> so no files are copied, as already present in
> targetdir ...
> 
> 
> Blank directorie are not copied, how to achieve that
> if wanted ?
> (manual says <cop<> task is set to
> ncludeEmptyDirs="true" ?
> 

I just tried this and blank directories _are_ copied. 
?

-Matt


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



      ____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 


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


Re: task to 'cp -r --reply=no'

Posted by Gilbert Rebhan <an...@schillbaer.de>.
Hi,

Matt Benson wrote:
> Hi Chris:
>   Try using a <present present="srconly" ... />
> selector with your source <fileset>.
> 
> HTH,
> Matt

Nice :-)


before =

J:\copyfrom\subdir1\
J:\copyfrom\subdir1\build.xml
J:\copyfrom\subdir2\
J:\copyfrom\subdir2\subsub2\build.xml
J:\copyfrom\build.xml

and
J:\copyto is a blank directory

with =

<?xml version="1.0"?>

<project name="bla" default="main">

   <target name="init">
     <fileset dir="J:/copyfrom" includes="**/*.xml" id="newfiles">
       <present present="srconly" targetdir="J:/copyto"/>
     </fileset>
   </target>

     <target name="main" depends="init">
     <echo>
      Files to copy = ${line.separator}${toString:newfiles}
     </echo>

     <copy todir="J:/copyto">
       <fileset refid="newfiles"/>
     </copy>

   </target>

</project>

first run =

Buildfile: J:\eclipse_3_2\workspace\AntTest\test.xml
init:
main:
      [echo] Files to copy =
      [echo] build.xml;subdir1\build.xml;subdir2\subsub2\build.xml
      [copy] Copying 3 files to J:\copyto
BUILD SUCCESSFUL
Total time: 891 milliseconds

the blank directory gets filled with meat =

J:\copyto\subdir1\
J:\copyto\subdir1\build.xml
J:\copyto\subdir2\
J:\copyto\subdir2\subsub2\build.xml
J:\copyto\build.xml

second run =

Buildfile: J:\eclipse_3_2\workspace\AntTest\test.xml
init:
main:
      [echo] Files to copy =
BUILD SUCCESSFUL
Total time: 516 milliseconds

so no files are copied, as already present in targetdir ...


Blank directorie are not copied, how to achieve that if wanted ?
(manual says <cop<> task is set to ncludeEmptyDirs="true" ?


Regards, Gilbert






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


Re: task to 'cp -r --reply=no'

Posted by Matt Benson <gu...@yahoo.com>.
Hi Chris:
  Try using a <present present="srconly" ... />
selector with your source <fileset>.

HTH,
Matt

--- Chris Velevitch <ch...@gmail.com> wrote:

> On 6/12/07, Rebhan, Gilbert
> <Gi...@huk-coburg.de> wrote:
> > combine it with a condition, example =
> >
> > <!-- Check ob Modul bereits verarbeitet -->
> > <target name="check_erl">
> >    <condition property="${mname}.done">
> >      <available
> file="${ant.working.dir}/${mname}_script.params" />
> >    </condition>
> >  </target>
> >
> > and make your copy target depend on the target
> with condtion and unless
> >
> > <!-- Subroutine fuer Module mit Liefertyp build
> -->
> > <target name="build" depends="check_erl"
> unless="${mname}.done">
> > ...
> > </target>
> 
> That's fine for one file, but cp -r tranverses a
> directory tree of
> 1000's of files. What's the ant equivalent of cp -r
> --reply=no?
> 
> 
> Chris
> -- 
> Chris Velevitch
> Manager - Sydney Flash Platform Developers Group
> m: 0415 469 095
> www.flashdev.org.au
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



       
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/

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


Re: task to 'cp -r --reply=no'

Posted by Chris Velevitch <ch...@gmail.com>.
On 6/12/07, Rebhan, Gilbert <Gi...@huk-coburg.de> wrote:
> combine it with a condition, example =
>
> <!-- Check ob Modul bereits verarbeitet -->
> <target name="check_erl">
>    <condition property="${mname}.done">
>      <available file="${ant.working.dir}/${mname}_script.params" />
>    </condition>
>  </target>
>
> and make your copy target depend on the target with condtion and unless
>
> <!-- Subroutine fuer Module mit Liefertyp build -->
> <target name="build" depends="check_erl" unless="${mname}.done">
> ...
> </target>

That's fine for one file, but cp -r tranverses a directory tree of
1000's of files. What's the ant equivalent of cp -r --reply=no?


Chris
-- 
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
m: 0415 469 095
www.flashdev.org.au

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


RE: task to 'cp -r --reply=no'

Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.
Hi,

-----Original Message-----
From: Chris Velevitch [mailto:chris.velevitch@gmail.com] 
Sent: Tuesday, June 12, 2007 10:12 AM
To: Ant Users List
Subject: Re: task to 'cp -r --reply=no'

/*
The copy task states "By default, files are only copied if the source
file is newer than the destination file, or when the destination file
does not exist", but in my case I only want to copy files if "the
destination file does not exist".
*/

combine it with a condition, example =

<!-- Check ob Modul bereits verarbeitet -->
<target name="check_erl">
   <condition property="${mname}.done">
     <available file="${ant.working.dir}/${mname}_script.params" />
   </condition>
 </target>

and make your copy target depend on the target with condtion and unless

<!-- Subroutine fuer Module mit Liefertyp build -->
<target name="build" depends="check_erl" unless="${mname}.done">
...
</target>


Regards, Gilbert

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


Re: task to 'cp -r --reply=no'

Posted by Chris Velevitch <ch...@gmail.com>.
On 6/12/07, Rebhan, Gilbert <Gi...@huk-coburg.de> wrote:
> "if the file exists ..."
> the copy task's default is overwrite false

The copy task states "By default, files are only copied if the source
file is newer than the destination file, or when the destination file
does not exist", but in my case I only want to copy files if "the
destination file does not exist".


Chris
-- 
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
m: 0415 469 095
www.flashdev.org.au

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


RE: task to 'cp -r --reply=no'

Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.
 
Hi,


-----Original Message-----
From: Chris Velevitch [mailto:chris.velevitch@gmail.com] 
Sent: Tuesday, June 12, 2007 9:46 AM
To: user@ant.apache.org
Subject: task to 'cp -r --reply=no'

/*
What task is the equivalent of 'cp -r --reply=no'. This command
recursively copies files and if the file exists in the destination,
skip copying that file and continue.
*/

<copy ...>
<fileset ... />
</copy>


from the manual

<copy todir="../dest/dir">
    <fileset dir="src_dir">
      <exclude name="**/*.java"/>
    </fileset>
  </copy>


**/ .... means recursive, see =
http://ant.apache.org/manual/dirtasks.html for those patterns

"if the file exists ..."
the copy task's default is overwrite false


Regards, Gilbert

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