|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 5
While it took several lines to explain the example, it should be evident that Ant is an easy-to-use tool. Using this buildfile
as a starting point, you should be able to incorporate Ant into your development effort. The ant commands shown in the above example have further functionality, some of which will be discussed in this article, the remainder
is left to you along with references to the documentation.
It is left to you to read through the built-in tasks included in the Ant distribution. See the user guide in Resources for information about each command. I have chosen two commonly used commands as examples of additional options available to the build manager without any customization.
In the simple example discussed earlier, you saw a simple form of the javac command. Now, if you examine it in more detail, you see that you can specify the compilation flags such as deprecation, debug,
or optimize as well as the files that will or will not be included in the compilation.
<javac srcdir="${src.dir}"
destdir="${build.classes}"
classpath="${classpath}"
debug="on"
deprecation="off"
optimize="on" >
<include name="**/*.java"/>
<exclude name="**/Script.java" unless="bsf.present" />
<exclude name="**/version.txt" />
</javac>
You can use the include/exclude entities inside the javac task to include/exclude files matching the pattern in the name attribute from the compilation. From the above example, you want to include files contained in any directory ending in .java
but, at the same time, you want to exclude files named Script.java unless a property bsf.present is set to true.
You set the bsf.present property using the following task that searches the classpath for the classname specified and sets bsf.present according to the search results:
<available property="bsf.present" classname="com.ibm.bsf.BSFManager" />
The javac command will not include files called version.txt from the compilation based upon the exclude command above.
Another task that Ant can help automate is the generation of javadoc. You can use the following command to generate the javadoc:
<javadoc packagenames="${packages}"
sourcepath="${basedir}/${src.dir}"
destdir="${build.javadocs}"
author="true"
version="true"
windowtitle="${Name} API"
doctitle="${Name}"
bottom="Copyright © 2000 GroupServe. All Rights Reserved."
/>
The packages specify the overall packages that the javadoc will include. The sourcepath attribute points towards the location of the source files. The javadoc command also provides attributes allowing you to specify the title of the window and the document. You can also include a
copyright notice at the bottom of each javadoc page, using the bottom attribute.
At this point, you have seen some of the possible tasks in your build process that Ant can automate. Those tasks are included out of the box in Ant. You might want to customize Ant to help you perform some more difficult tasks such as building EJBs and performing remote configuration management. Some of you may want to increase Ant's reporting capabilities or construct a user interface that can run the Ant process.