Tuesday, October 05, 2004

Interim addition on ANT

Before I finish my second part on error-handling/reporting in ANT, I will explore how to deploy ANT in a production environment.

The default distribution of ANT provides platform independent scripts that enable ANT to be deployed to different platforms. However, the default installation instructions pollute the host environment with the ANT_HOME variable. In a production environment, having multiple applications depend on a single ANT instance may create undesired dependencies.

One solution to this problem is to specify only the ANT_HOME and ANT_HOME/lib variables at execution time, so that each application can have a different ANT location.

In Windows, you can wrap around your ANT execution by creating a .bat file with the following commands:

set ANT_HOME=${ACTUAL_ANT_HOME_DIR}
set PATH=%PATH%;%ANT_HOME%/bin
ant ${TargetName}

In Unix, you can create a shell script that duplicates the functionality above:

ANT_HOME=${ACTUAL_ANT_HOME_DIR}
PATH=%PATH%;%ANT_HOME%/bin
ant ${TargetName}

One disadvantage of this approach is that the actual command is not platform independent. As of version 1.6.2, ANT allows you to specify the above information in a single line of code which is compatible with both Windows and Unix. You can simply launch the ANT environment by issuing the command:

java -classpath "${ANT_LIB_DIR}/ant-launcher.jar" -Dant.home="${ANT_HOME_DIR} -Dant.Dant.library.dir="${ANT_LIB_DIR}" org.apache.tools.ant.launch.Launcher ${TargetName}

0 Comments:

Post a Comment

<< Home