Intranet Journal   Earthweb  
Events Jobs Premium Services Media Kit Network Map E-mail Offers Vendor Solutions Webcasts

   Intranet Journal Subjects
Search Earthweb

Privacy Policy



internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

internet commerce
Be a Commerce Partner
















 

[ Home | Discussion Forum | How Do I... | Lotus Notes Intranets | Microsoft SharePoint | Products | Shopping  ]

free news!


A Little Ant Can Lighten the Load


P.G. Daly
12/12/2002

Go to page: 1 2 

Printer Friendly Version

If you are developing Java-based Web applications and you're still manually building and dragging and dropping files from one place to another, now is a good time to consider automating. Ant is an open source Java-based build tool that is available from the Apache Jakarta Project Web site. Ant differs from other build tools in several ways.

Not OS Dependent
Since Ant is not OS dependent, you can develop one standard build file for your projects and then re-use this code for any similar projects, regardless of the platform. Because the tool is not married to any one platform, you can capitalize on the "write once, run anywhere" philosophy.

Extended Using Java Classes
Unlike tools such as make, jam and others, Ant is extended using Java classes rather than shell-based commands. The good news is that Ant provides you the capability of constructing shell commands without the inherent limitations of having the tool's foundation built on shell commands. In addition, you can extend Ant further by writing your own custom tasks and packaging them into a jar file that resides within the Ant installation.

Easier Syntax
Ant is based on XML configuration files. This means the build files are extremely easy to work with and read since they follow XML standards. This offers a huge benefit over tools such as make that use a more algorithmic syntax. For example, a simple make example would look like this:


gcc -c a.c
gcc -c b.c
gcc -o ab a.o b.o
That's not very intuitive, or easy to work with, unless you are a UNIX wizard.

Ways to Use Ant in Intranet Development
Before I get into the background and nitty-gritty of how to use Ant, let me briefly discuss some reasons why you might want to use Ant on your intranet development projects.

Most Intranet teams have multiple members working on different projects with regular (usually at least weekly) release schedules. In this scenario, you want to avoid having the project leader becoming a bottleneck, while at the same time enforcing a degree of standardization and consistent work processes. Ant is a great tool for this. You can create one build.xml file for the entire team to use for all their projects. With this one build file you can:

  • ensure a common build that will work in your production environment by ensuring that everyone is compiling against the same common jar files.

  • enforce the use of a source code control system by integrating your configuration management processes and tools with the Ant build scripts.

  • provide a means to consistently deploy applications to different Web servers and keep the releases clean, consistent and accurate.

If, like me, you get instantly overwhelmed when you read a variety of complex introduction and example type articles, searching the Web for articles on Ant can stress you out, because Ant is so extendable and customizable. My advice is to start small with understanding the tool and build on it from there. Since I had the advantage of working with an in-house Ant guru and well-designed code I could re-use, I would like to share some basics and do my best to get you off on the right foot.

Getting Started
Getting started is a breeze. Simply download the latest version (currently 1.5.1) and install Ant using the installation instructions. If you want to become vaguely familiar with its workings, you can also peruse the manual.

Regarding installation and configuration, it is important to make sure you set your environment variables properly (otherwise nothing will run.). For this example, assume we installed Ant in c:\ant and your Java Development Kit (JDK) is installed in c:\jdk. After installation set the following:

  • Set your ANT_HOME to the root of your Ant installation (c:\ant)
  • Set the PATH variable to the Ant binaries (c:\ant\bin)
  • Set JAVA_HOME to the root of your JDK (c:\jdk)

Running Ant
Running Ant from the command line is simple. Assuming you correctly set up all the environmental variables upon installation, all you need to do is type ant at the command line. If you include no other arguments, Ant will search for a build.xml file within the current directory. Once it locates the build.xml file, it will execute the target specified in the default attribute of the <project> tag.

In addition, you can set properties and a host of other options via the command line. You can find a complete listing of these in the Command Line Options Summary section of the manual.

You are probably thinking, "Huh? What is a build.xml file and what are these tags and attributes you speak of?"

Go to page: 1 2

Printer Friendly Version

Of Interest
Intranet eXchange Discussion Board
Practical XML for the Web
The JARS Java Resource Center

email this page

Tutorials
and more at:
Intranet Journal's Tutorials
Intranet Journal Favorites

Creating a PHP-Based Content Management System

The Spyware Guide

Introduction to Microsoft SharePoint Portal

Intranet Journal
Part of the EarthWeb Network

Managing Editor
Intranet Journal

Tom Dunlap

EarthWeb Home Page
Jupitermedia Home Page

Media Kit




The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers