My blog has moved
Please update your bookmarks and feeds for my site.
I now have a Mango Blog at:
http://www.andyjarrett.com/blog
Feed URL: http://feeds.feedburner.com/andyjarrett
Please update your bookmarks and feeds for my site.
I now have a Mango Blog at:
http://www.andyjarrett.com/blog
Feed URL: http://feeds.feedburner.com/andyjarrett
Critter on a previous post asked "if you can pass in attributes to the build.xml file?" From the Terminal this is as easy as adding another argument "-D".
-D<property>=<value>
This will update a property in you build.xml file with the value you passed in
For example you would use something similar to
Putting this into practice here is a sample build.xml which I am going to save to my Desktop
From the Terminal no run
In your terminal window you should see something like
I'm gonna try and cover the two OS's here so be kind.
First things first, goto http://ant.apache.org/bindownload.cgi and download the appropriate archive (zip) file: apache-ant-[VERSION NUMBER HERE]-bin.zip
Then for Windows: Extract the .zip to c:\ant. From the command line set the following environment variables:
Now open up the Terminal(Mac)/Command line(Win) and just type "ANT" and hit return. You should see:
To demonstrate calling a file we're gonna create a quick build.xml. Create a new text file, enter the following bit of XML and save it as build.xml
If you are on Windows save this file to the root of c:\ and from the command line run the following
That's pretty much it, from here you you are now set to run Ant from the Terminal/Command line so in theory you should be able to schedule tasks etc!
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:
Before we jump in, if you are on Unix then know that the file permissions are not retained when files are copied; they end up with the default UMASK permissions instead. This is down to the current Java runtimes and the inability to set the permissions. You can get around this by using ANT to call Copy Path view the terminal i.e.
Lets begin!
Create a new project in your Eclipse workspace. The type of project doesn't matter, though I'm creating a CFEclipse one as I want to cpoy .cfm pages. From within the project create a new file called Build.xml. Create two more folders in your Ant project called 'folder_test' and 'folder_live' and in the first folder put a file called 'index.cfm'. Your project should now look like this
The plan now is copy the complete directory of 'folder_test' to 'folder_live':
Of course there is more you can do, rather than going through full set examples here or some of the other features:
Copy a set of files to a directory
Copy a set of files to a directory, appending .bak to the file name on the fly
Copy a set of files to a directory, replacing @TITLE@ with Foo Bar in all files.
Collect all items from the current CLASSPATH setting into a destination directory, flattening the directory structure.
Copies some resources to a given directory.
Copies the two newest resources into a destination directory.
More resources:
First off I wanna say that I'm running all my Ant task 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.
So, what is Ant? Well to steal a quote from Mark Drew, think of Ant as .bat files on steroids. You use XML to describe a set of commands to run a whole range of tasks to do anything from SVN/CVS checkouts, unit tests, FTP, emails, sql, moving/copying folders/files generally just name it!
In this guide I want to cover creating a build.xml file and moving files/folders. 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.
Lets begin!
Create a new project in your Eclipse workspace. The type of project doesn't matter, though I'm creating a CFEclipse one as I want to move .cfm pages around. From within the project create a new file called Build.xml
In your build.xml add the following and save:Now while still in the editor right-click anywhere on your build.xml file and choose the following:
In the console window you should see something likeBuildfile: /[your eclipse work space root]/Ant/build.xml
[echo] Hello foo, I am the build.xml
BUILD SUCCESSFUL
Total time: 136 milliseconds
You've ran your first build.xml file excellent. Now lets move a file. Create two more folders in your Ant project called 'folder_test' and 'folder_live' and in the first folder put a file called 'index.cfm'. Your project should now look like this
The plan now is move the complete directory of 'folder_test' to 'folder_live':
Of course there is more you can do, rather than going through full set examples here or some of the other features:
Move a set of files to a new directory
Move a list of files to a new directory
Append ".bak" to the names of all files in a directory.
More resources:
Just been looking around for tips on installing Ant on the MacBook Pro and came across this. Not only is it a good guide but it takes time to explain the unix commands you are using.
Thanks to Eclipse making Ant so simple to use I've got it doing a few tasks for me. Well I thought I'd show how simple it is to use. Below is a simple Ant build.xml that I use to copy the ModelGlueAppliactionTemplate files over to a new project. In a nutshell it copies a bunch of files and directories from one location into the location the build.xml was ran from.
I've added a new pod to my site which now reads the ColdFusion Google calendar so you can see up coming events.
I've managed to add a couple of events myself including some from the Online CF meetup group, also thanks to Mark Drew as well as he is keeping up the UKCFUG schedule.
If you are an CFUG organiser (or any CF related organiser) leave me a comment here and i'll add you as an administrator so you can add your events. You'll need a Gmail account!
To subscribe to the calendar use one of the following links:
They say Laziness is the mother of all invention, well it strikes again. I've created another Ant build file for use with Doug Hughes Reactor. The build file will download the lastest set of Reactor files the Doug's SVN server, which at the moment has just reached a beta candidate.
The code for build.xml is below.
To run the file from Eclipse just put the file into any project, update line 9 (the <project> tag) with your Reactor folder location, right-click and then select "Run As -- Ant Build".
For anyone who is using Ant script to get the CFE nightly builds will need to update the srcURL property.
The srcURL should now be http://cfeclipse.org/nightly/cfeclipse_nightly.zip
Below is the updated code