I've been slowing building an Ant task I use to push my application to our development server.
It does the following:
- Creates a 'temp' dir on my local drive
- Checks out a revision from our SVN repository (I can enter a revision or HEAD via a prompt)
- It then 'cleans up' the checked out working copy (removes a few files, etc)
- Converts my CFC's to duck type* (using Adam Haskell's script)
- Replace a few tokens in application.cfm with some information about the build
- Zip up and copy the files to our development server and unzip them
- Delete all the temp directories and files and email a log
It does all that at the push of a button in CFEclipse.
While digging around recently I noticed a 'sync' Ant task and bookmarked it away for further reading. Today I finally had some time to check it out and it was really easy to implement!
My copy and ZIP code:
-
<target name="zipBuild" description="Set ZIP filename, then ZIP clean dir">
-
-
<property name="build.filename" value="myProject_${svn.versionnum}.zip" />
-
-
<zip destfile="${project.build.src}${build.clean}/${build.filename}" basedir="${project.build.src}${build.clean}" />
-
-
<copy todir="${project.build.dev}">
-
<fileset dir="${project.build.src}${build.clean}" includes="${build.filename}" />
-
</copy>
-
-
<unzip src="${project.build.dev}\${build.filename}" dest="${project.build.dev}"/>
-
-
<delete file="${project.build.dev}\${build.filename}"/>
-
<delete dir="${project.build.src}${build.temp}" />
-
<delete dir="${project.build.src}${build.clean}" />
-
-
<echo message="Files moved to development succesfully!"/>
-
</target>
To change it to use 'sync' instead was really simple - it was almost the same syntax as the copy task:
-
<target name="syncBuild" description="Sync files between 'clean' directory and server">
-
-
<sync todir="${project.build.dev}" verbose="true">
-
<fileset dir="${project.build.src}${build.clean}"/>
-
</sync>
-
-
<delete dir="${project.build.src}${build.temp}" />
-
<delete dir="${project.build.src}${build.clean}" />
-
<echo message="Files moved to production succesfully!"/>
-
</target>
Interestingly they both take almost exactly the same amount of time to run (~36 seconds) - I would have thought sync would have been a bit faster without the overhead of zipping and unzipping.
Next I need to add in some dependencies between targets to make sure everything runs correctly and in order and add our production server and I should be done!
If you haven't checked out Ant yet - do it! It's a great tool!
I have a lot of Ant links on my wiki!
* Please note I didn't do this for performance reasons, it was more along the lines of 'because I could'

You May Also Enjoy Reading: