So, I had a bit of a play, and came up with two ANT scripts that I thought I'd share, to save other innocents the buttock-clenching frustration that ANT development on Windows can be.
The first script is to be run on your development machine, and it's called build.xml
This build script:
- Connects to a given repository repository
- Exports all files in a given revision from the given folder to a temporary directory
- Zips up all files within that temporary folder which have been modified since a given date
- Clears up the temporary folder
…producing a timestamped zip file containing all files changed since a given date.
You can then upload the zip file to the live server and extract it over the live code using the second script, release.xml.
This second script:
- Scans the build/ directory for build_*.zip files
- Asks you to choose the build file for release
- Backs up all files contained in the zip file to the build/ directory
- Extracts the build_*.zip over the top of the existing files
giving you a backup file called BACKUP_(whatever your build file was called).zip, which you can easily re-apply if something goes wrong with your release.
So, to run the build.xml file on your dev machine, you will need :
- A working install of Apache ANT
- The SVN ANT custom ANT task
- A working Subversion (SVN) repository
- Plus these files: build.xml, build.properties, svntask.properties
You can download all the above in one package here : build_release_files.zip
I'd recommend that you put the three files in the root of your project - most projects I've worked on tend to have a structure along the lines of:
- components (or custom tags, or whatever)
so i've written the scripts on the basis of them being in the project root.
One thing to note : you'll need to set the repoURL value in build.properties to the default url of your repository in SVN, something like svn://yourserver/yourrepository/trunk
To run the script, just open up a command prompt, cd to the project root directory, type:
and follow the on-screen prompts.
This will produce a build file in the Project Root/build/ subdirectory, which will be created if necessary.
On your live server, you'll need a working installation of ANT, plus this file : release.xml
Again, put this in your project root directory on the live server.
To run it, again open a command prompt and cd to the project root directory, but this time type:
ant -f release.xml
to make ant execute the file release.xml (by default it looks for build.xml)
It will look for zip files in the Project Root/build/ subdirectory, so make sure your build .zip file is in there. Again, it prompts you for everything it needs.
Standard legal disclaimer bumph: these files are provided as is, use them at your own risk, if it makes a mess of your server, it's entirely your own fault and I'm not accepting any responsibility whatsoever. Nope, none. Sorry...