Backing up your files with Ant and Eclipse
Tagged Under : ANT, Eclipse
I have heard a lot about Ant for years now but being a CF developer, never really had the need to use it, or I must say, never bothered to use it. However, recently, I read some blog posts about this and I was very impressed by its power and the opportunities it opens. So I decided to give it a try. Because I use Eclipse for development, it made my life easier as it comes with the Eclipse installation. All I had to do was to create a new Eclipse/CFEclipse project and throw in a build.xml file and then rock n roll.
As my first attempt with Ant, I decided to work on a build file that would take all my source files from a folder, zip them up and save the zip file into a backups folder giving the zip file a timestamp based name. Sounds very easy to do with a CF script but this time around I was gonna try to do this with a Ant build file.
Here is what I did :-
- Create a new Eclipse Project(I called it AntProject)
- Create a folder(srcFiles) and put some files in it.
- Create another folder (backups).
- Create a blank build.xml in the root of the Project.
- Copy the following code to the build.xml file.
Thats it! You can now run this project by right clicking on build.xml and then “Run As - Ant Build”
That should open up your Console window when you run this but to open the console window manually, you can do this.
Window -> Show View -> Other -> General -> Console.
If everything goes fine, you should see a zip file in the backups Folder. Really Cool! I am impressed. Now only if I can figure out how to do that each time I close my Eclipse without having to run it manually.
You have a small issue with this line:
“”
The needs a / in it at the end according to my console error that I got from eclipse. Thanks for writing this up!
Sorry, your zip line needs to be:
<zip destfile=”${destDir}/${zipFilename}” basedir=”${srcDir}” update=”true” />
@Todd,
Oh yeah, I missed the closing line while posting this. Thanks for pointing it out.
OMG, that is so quick and it allows a mapped drive for the destination (unlike SVN).
Thanks for the help… this ant its great.