Get ANT up and Running - CI for ColdFusion Devs

A while back - too long ago - I started a series of blog posts about getting up and running with Jenkins for continuous integration.  I left off with talking about Apache ANT (which stands for Another Neat Tool).  ANT is basically XML which allows you to tell Jenkins the steps you'd like to take to "build" your site continuously.  Installing ANT was not as straightforward as I thought, so I'd like to share a bit of my experience so that hopefully it will be smooth sailing for you.

Overview

You are going to be installing two pieces of software - a Java Development Kit and then Ant.  Where you install these items is important.  Please be aware of this and it will prevent you from wanting to impale yourself. If you're on Windows 7, you may have noticed that there are two places where your program files might be saved on your hard drive: 

  • c:\Program Files
  • c:\Program Files (x86)

Wikipedia says, "64-bit versions of Windows have two folders for application files; 'Program Files' folder serves as the default installation target for native (in this case 64-bit) programs, while the 'Program Files (x86)' folder is the default installation target for non-native (in this case x86-32) programs."  

Here's how you can (and should) check what your JAVA_HOME path is:

Open the command line (click start, type "cmd" and then enter). When the command line opens type "echo %JAVA_HOME%" and then enter. Note the path that is returned.  This is your Java home path. I will presume that it is c:\Program Files (x86)\Java like this:

If c:\Program Files (x86)\Java isn't your Java home path, leave a comment at the bottom of this post and I'll talk you through what to do next.

Step 1. Install the Java Development Kit

Go to this address: http://bit.ly/16HcfHy, accept the license agreement and download the appropriate Java Development Kit.  Important: If you are on a 64-bit version of Windows click the jdk-7u21-windows-x64.exe link.  If you're on a 32-bit version of Windows click the jdk-7u21-windows-i586.exe link. If you're on a Mac or other _nix machine Im guessing you know what to do ;)

After the file downloads, go ahead and start the install.

Click Next

Note the "Install to:" path. You're going to change this to c:\Program Files (x86)\ so click the "Change..." button

Browse to the correct Java home path and click OK

Now that you have the correct path click Next and the install will begin

 

When the install is complete you'll see the following screen:

Click Close because you're done! Now on to the ANT part.

Step 2. Install ANT

Go to this link: http://bit.ly/10RiFfg and click the "Download the latest verson" link from under the "get it" title.

After it downloads, double-click to begin the installation.

Click Next

Click Next again

Click the "..." to choose the directory of your Java home path  - c:\Program Files (x86)\Java

Click Next

Choose the default location for installing ANT which should be c:\Program Files (x86)\WinAnt and then click Next

The install will begin

You may get a pop-up notification about having to log out and back in.  Just click OK.

If you click the "Show Details" button you can see everything that's happened (or happening) during the install, but you're not required to do so.

When the installation is complete you'll get a pop-up asking if you'd like to donate to WinAnt.  You don't have to but it's good karma ;)

Click Close and you're done.  Now you need to verify that everything went as planned.  If you have a command line window open, close it and re-open it.  This will assure that nothing is cached.  In the newly-opened command line type "ant -version".  You should see the following:

Thats it.  Congratulations, ANT is up and running on your machine.  Next post will explain more about what it does and the scripts you can write.

I noticed that the vast majority of folks who had issues were trying to install a JRE (Java Runtime Environemt) rather than the JDK (Java Development Kit).  Please be careful with this.  If you use the links to the installers I provided you shouldn't have a problem.  If you do, let me know and I'll try to help you out.

As an important footnote, it wasn't until I was almost done with this post that I noticed Steven Neiland had written a blog post on almost the same exact thing.  My approach is slightly different and easier in my opinion because it makes use of installers.  Steven's approach has links to the latest version of ANT while WinAnt might not always be updated to the latest version.  You can see his blog post here: http://bit.ly/10RgEzC and follow Steven on Twitter @sneiland - he has lots of great information!!

Cheers!

 

  1. jim priest

    #1 by jim priest - May 21, 2013 at 6:22 AM

    Added to my any wiki - http://www.thecrumb.com/wiki/ant

    Hopefully it will help others!
    Thanks!
  2. Carl Von Stetten

    #2 by Carl Von Stetten - May 21, 2013 at 1:48 PM

    Kris,

    I'm curious what the reason is that even a 64-bit JDK on Windows 7 64-bit would need to be installed in the "Program Files (x86)" folder?

    By the way, on my development laptop (Windows 7 64-bit) with both 32- and 64-bit Java client and 64-bit JDK installed, my Java_Home environment variable is undefined.

    -Carl
  3. Kris Korsmo

    #3 by Kris Korsmo - May 21, 2013 at 2:26 PM

    Carl - I'm still learning this stuff too, so hopefully someone can give you a more definitive answer, but I'm fairly certain you *can* install the JDK in the 64-bit Programs folder - it'll just require modifications to the environment variables. I actually tried that a couple times and was not able to get it working. I found that the WinAnt installation always looked in the x86 directory for tools.jar, and even if I added it to the path it wouldn't work. I'm not sure if that was a WinAnt thing, a bad environment variable or simply me missing something.

    So with your Java_Home variable undefined are you having success running ANT? What does your Path environment variable look like?
  4. Carl Von Stetten

    #4 by Carl Von Stetten - May 21, 2013 at 2:32 PM

    Kris,

    Looks like the Ant installer will set the JAVA_HOME environment variable for you, along with ANT_HOME, although it sets them as user variables rather than system variables.

    My Java 7 JDK was already in C:\Program Files, so I left it there. Ant installed okay. Not sure what to do with it yet, I guess I'll wait for your next blog entry to see what I can do! ;-)

    -Carl
(will not be published)
Leave this field empty: