Ant: Copying files and directories

I know that I've done a post on copying files with Ant, but I really want to take this further and into more detail. To save my fingers a lot of the text below is taken from my first post as moving and copying directories/files is a similar command in principle.

I also want to mention that I am running all my Ant tasks via Eclipse and not the command line. If there is a demand to know how to install Ant and run it from the command line I'll do that post separately. At this point I'm assuming you've got Eclipse and you know you way around it enough? Before we do begin you will need to ensure that you can see the Console 'View', you can get to this by going to:

Posted: 24-Jun-2007

View: 30154

Permalink: here

Comments

Hi Andy
Nice post!
Here is a usefully ANT script i use to just upload files ive worked on since starting my latest update...

[fileset dir="${basedir}" id="changedFiles" ]
[and]
[date datetime="6/25/2007 9:00 AM" when="after" /]                    
[/and]
[/fileset]

I then wrap that in a FTP task when i need those files to go to a remote server rather than a file i have mapped.

Pat

#1 Pat Branley
25/Jun/07 12:44 AM

Cheers Pat, I'm gonna cover FTP in another post soon :o)

#2 Andy J
25/Jun/07 7:53 AM

Great stuff! I love Ant! Hope you don't mind but I've added your Ant related posts to my wiki:

http://www.thecrumb.com/wiki/Ant

#3 Jim Priest
25/Jun/07 1:01 PM

Hi,

I'm trying sort my input to the concat task alphabeticly with this:

   <concat destfile="${temp}/s3/management.css">
   <sort>
         <!--this sort does not work if there are over 9 files -->
         <name xmlns="antlib:org.apache.tools.ant.types.resources.comparators"/>
            <fileset dir="${temp}/assets/min/css/" includes="*.css"/>
      </sort>
</concat>

My files are named 1styles.css, 2styles.css, 3styles.css, etc. However, once the count reaches 10 the order gets messed up and 10styles.css is loaded first.

How can I load them by the numbers 1-10 ?

#4 Alex Egg
24/Jul/07 3:14 AM

How would I:

I would like to copy my project files from their location to another location outside of my project?

More detail, I'm writing php and I am looking for a way to just be able to run my ant file and have it copy the files to my iis directory which is somewhere else on my computer. If it could do a file compare and only transfer the files recently modified would be awesome. Then also I would like to learn how to also do this over SSH where it will open up a connection and transfer files over ssh. Currently I use WinSCP and it's compare functionality to make a SSH connection, compare files I've changed, then upload only my changes.

#5 Mike
25/May/11 5:35 PM