| Step 6: Build | previous contents next |
classes directory of the
tutorial project:
build.xml file according to
your needs and choose 'Run Ant' from the 'Ant Runner' submenu in the
'Tools' menu:
out path of your Together installation.
tools/ant of your JUnitX or XPTest
distribution or the tutorial.
Use tools/ant/bin/ant (Unix) and tools/ant/bin/ant.bat
(Windows) later to start Ant.
On Windows 95/98, the Ant launch script will have problems with the limited
environment space if the variable ANT_HOME is a long filename. This is
due to limitations in the OS's handling of the "for" batch-file statement.
It is recommended install Ant in a short path, such as D:\Ant.
The tutorial assumes that you work on Windows NT/2000 or Unix.
build.xml.
Create such a file in the main directory of the xptest-tutorial
project with the following content:
<project name="URLParser" default="main" basedir=".">
<property name ="prj.dir"
value="/shared/extreme-java/xptest-tutorial" />
<property name ="junit.jar"
value="/shared/extreme-java/xptest-tutorial/junit-3.7.jar" />
<property name ="junitx.jar"
value="/shared/extreme-java/xptest-tutorial/junitx-5.0.jar" />
</project>
|
<project> and
the closing tag </project> define our project. The attribute
name="URLParser" defines the project name.
basedir="." defines the current directory where Ant is
started as the base directory for Ant.main targetdefault="main".
Now its time to define that target between the properties and the
</project> tag:
<target name="main" depends="clean">
<mkdir dir ="${prj.dir}/classes" />
<javac srcdir ="${prj.dir}/src/"
destdir ="${prj.dir}/classes"
includes="**/*.java">
<classpath>
<pathelement location="${junit.jar}" />
<pathelement location="${junitx.jar}" />
</classpath>
</javac>
</target>
|
classes is generated based on the value of the property
prj.dir. Afterwards the compiler is run. It gets the
path (srcdir="${prj.dir}/src/") where the sources are located.
Here the value of the property prj.dir is referenced by
${prj.dir}. Afterwards the output path
(destdir="${prj.dir}/classes") and the files to parse
(includes="**/*.java") are defined. '**' stand for
any number of nested paths.clean targetdepends="clean" of the project tag shows, the compilation
is started after a clean up has been done. Here is the code for
cleanup:
<target name="clean">
<deltree dir="${prj.dir}/classes" />
</target>
|
build.xml file. Or you can run Ant
by hand as described below.
If you are using Windows 95 or 98, you need to reconfigure your
dos box to provide 4096 bytes for environment variables. You can open the
appropriate configuration pane by starting a dos box and clicking on
the 'MS DOS' icon in the left upper corner:
/shared/extreme-java/xptest-tutorial) and starting Ant
(e.g. /shared/extreme-java/xptest-tutorial/tools/ant/bin/ant.bat). The
output looks like this on my Win 98 box:
classes directory created
by Ant:
| previous contents next |
© 2001 A. Heilwagen