Jeff Chastain is one of "those" developers who grew up taking summer programming classes in grade school just for fun. He used that strong foundation to create a career out of developing software applications using object-oriented programming, which Jeff has been doing for more than a decade, including more than eight years with Adobe toolset-based applications. His current work focuses on object-oriented programming and project management for a variety of clients in order to help them streamline processes and improve user experiences. Jeff is highly adept at evaluating an entire application to break it down into manageable parts for development using a variety of different frameworks. He is an accomplished writer who has published a number of articles in various industry publications.
Here at Alagad, we are in the business of not only writing code, but developing and deploying enterprise class applications. Doing this properly involves a lot more than just writing ColdFusion, Flex, etc. code. When developing an application, we have distributed development environments, a testing/staging area, and a production/release area. We use Subversion for source control and a variety of other testing tools. One of the problems that comes up with a situation like this is how do you get code out of Subversion, to the development environment, then to testing and production while maintaining the integrity of the application and all of its configuration?
The answer I have always given other developers when asked this is something called ANT. However, I have never really used ANT myself and have never really explored under the covers to see what is really possible. The point of this posting and several more to come is to take you along on my journey into all that is Apache's ANT.
So what is ANT?
When you write code in languages like Java or C, you must run a separate compile/build process afterwards before you can actually deploy the code. With ColdFusion, this is handled for us under the covers and we don't have to worry about it. There are a variety of tools out there for compiling and building applications, but they are typically platform dependent and not the most user friendly. So, one day, Mr. James Davidson, a Java developer got tired of this situation and wrote his own tool which he called Another Neat Tool, or ANT for short. ANT started out being used by several Apache Jakarta projects and quickly spread through the Java developer community and beyond, becoming the standard for automating the build and deployment process for software projects.
ANT is written in Java, so it is platform independent and easily usable for any developer. ANT makes use of XML based build files which provide the instructions for what the ANT deploy process is supposed to do. These XML files can be created and managed in any XML editor and are easy to use and validate.
strong>Installing ANT
ANT can be downloaded from the Apache site at http://ant.apache.org/ and there are a variety of package types to choose from, although they should all end up with the same result based upon your OS. After you have "installed" ANT - it was just a matter of unzipping it for Windows - there are a couple of other things you need. First off, you need a Java JDK - at least version 1.2 and 1.5+ is currently recommended. According to the documentation, the higher the JDK version is, the more features of ANT you will have at your disposal. Once you have ANT and the JDK, you will need to add the file path to the BIN folder inside of the ANT folder to your class path. You will also need to create two environment variables - one called ANT_HOME which points to the ANT folder and one called JAVA_HOME which points to your JDK. For my setup on Windows, these paths look something like this:
Now What?
Now that you have ANT installed, what do you do with it. First off, I setup a simple little build.xml file just to make sure ANT was working. The contents of this build.xml file looked something like this:
<?xml version="1.0"?>
<project name="demo" default="help">
<description>Test build.xml</description>
<target name="help" description="usage information for common tasks">
<echo>usage: ant [target]</echo>
<echo>typical targets: init, dist, deploy, clean, help </echo>
</target>
</project>
Buildfile: build.xml
help:
[echo] usage: ant [target]
[echo] typical targets: init, dist, deploy, clean, help
BUILD SUCCESSFUL
Total time: 0 seconds
Looking Ahead
Now that I have ANT setup and running, I have to go do some more digging as to the syntax and possibilities for the build.xml file. As soon as I have more, I will post it here. Some of the things I am looking to do with ANT include:
You could start with this old article I wrote for (shudder) CFDJ http://coldfusion.sys-con.com/read/43787.htm
As an aside, the way to remove all of the "junk" .svn files from your code base is to do a svn *export* command. That gives you a clean copy of everything.
dbUnit is probably what you want to look to for dealing with manipulating the database
I cover most of this in my Ant and dev process talks at CFUnited fwiw.
http://www.thecrumb.com/wiki/Ant - has examples for most of what you mentioned in the looking ahead section.
Posted By: Mike Henke on Oct 8, 2007 at 12:00 AM