I. Installing AntANT is an utility that comes from apache. Under Unix, we need a Makefile to make a command before execution. Ant has the same effect. To install it, go to ant.apache.org and download both the binary distribution and the source distribution. 1. The binary distribution contains the following directory layout: . ant . README, LICENSE, fetch.xml, other text files.(basic information) . bin (contains launcher scripts) . lib (contains Ant jars plus necessary dependencies) . docs (contains documentation with various logos for html documentation and a manual (Ant documentation)) . etc (contains xsl goodies to: - create an enhanced report from xml output of various tasks. - migrate your build files and get rid of 'deprecated' warning - and more) Only the bin and lib directories are required to run Ant. To install Ant, choose a directory and copy the distribution files there. This directory will be known as ANT_HOME. ANT_HOME = C:\Program Files\Ant Add the bin directory to your path: C:\Program Files\Ant\bin The classpath (optional) for Ant must contain ant.jar CLASSPATH = C:\Program Files\Ant\lib\ant.jar Set the ANT_HOME environment variable to the directory where Ant is installed . 2. Create a directory (Source) in ANT_HOME and copy there the source distribution thet contains among the others build.bat and build.xml. II. Installing build directory:By running C:\Program Files\Ant\bin>ant -version If we get: Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.5.0_14\lib\tools.jar Then copy tools.jar from C:\Program Files\Java\jdk1.5.0_14\lib\ to C:\Program Files\Java\jre1.5.0_14\lib\ And we will get things working: C:\Program Files\Ant\bin>ant -version Apache Ant version 1.7.0 compiled on date ( xxxx xx xx) We need also to copy javac from C:\Program Files\Java\jdk1.5.0_14\bin\ to C:\Program Files\Java\jre1.5.0_14\bin\ WE are now ready to build Ant: Use the command: C:\Program Files\Ant\Source> build install Or better: Just double click on duild.bat This will build the build directy in the current directory, that is: C:\Program Files\Ant\Source\ III.Using Ant (example of Java file):Create a working directotyC:\ANT_to_Work Set a windows prompt:C:\ANT_to_Work> WE will separate the source from the generated (classes) files, - Java source files will be in src folder, and - All generated files under build folder whic will be splitted into several subdirectories: classes files and JAR-files. We have to create only the src/sub directory. C:\ANT_to_Work> md src/Regards And place there the following Java file named The_best.java:
package Regards; Compile like this: C:\ANT_to_Work> javac -sourcepath src\Regards -d build\classes src\Regards\The_best.java And run that: C:\ANT_to_Work> java -cp build\classes Regards.The_best The output is: Regards and all the best of luck. |