• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[ant] copy, creating directories as needed

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to copy a set of files and directories to another location, but the directories don't exist in the new location. As such, I get an error that they don't exist. I need the copy process to copy files and directories recursively, creating directories as needed.
I have checked the task documentation, but I can't seem to come up with a simple way to do this.
Any suggestions?
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you taken a look at the mkdir task? It allows you to create directories.
 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure - I use mkdir all the time.
The problem is in copying a set of files and directories that I don't know the composition of - I want to pick them up and copy them without having to know what sub-directories exist.
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, if you use mkdir task to create the top level that you want to copy into the copy task should take care of the rest.
One thing you might do is create an init task that will create the top level directories and make this and other tasks which may need those directories depend on that init task.
 
timothy zimmerman
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn't have to know the directory structure beneath that which you are copying the copy task should handle that for you. Have I misunderstood something?
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about using "mkdir"'s -p option?
will that help at all ?
 
timothy zimmerman
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is the unix mkdir command? I believe Ant's mkdir task behaves like mkdir -p by default.
 
Raj Birru
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Timothy, thats right -p option is unix mkdir option. I didn't know that Ant's mkdir is same as mkdir -p. Thanks for the info.
 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've tried using the copy task to copy files recursively into a root directory that exists (none of the subdirectories exist). It works perfectly.
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my code I have a dependency that creates the directories [ which it sounds like may not be necessary looking at these posts] and when I use a copy task it handles the rest recursively.
Here's my example:
 
Chris Reeves
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greg, I create the directories for build in my prepare task too. I have another task that blows them away too - it's nice to get a clean start from time to time.
 
reply
    Bookmark Topic Watch Topic
  • New Topic