Apache Ant is a software tool for automating software build processes (like GNU Make). I used Ant to build the Adroid version of a doc set from within the Eclipse IDE.
Note: The name Ant is an acronym that stands for Another Neat Tool.
Ant homepage
Installation and setup
The oXygen XML Editor uses it’s own version of Ant. To get oXygen to work properly, you have to make it’s Ant installation the primary Ant installation located in C:\opt\eclipseplugins\com.oxygenxml.editor_16.1.0.v2014102117\tools\ant.
- Delete the standalone Ant in: C:\apache-ant-1.9.2.
- There’s another standalone version located in: C:\Users\Chris\.ant. Delete it.
- Leave Eclipse Ant in: C:\opt\eclipseplugins\org.apache.ant_1.9.2.v201404171502. You should leave this so you can set controls for it (i.e., set preferences in Eclipse). You can set it up to use oXygen’s Ant installation.
Set the environment variable
In Windows
- Create the new environment variable ANT_HOME=C:\opt\eclipseplugins\com.oxygenxml.editor_16.1.0.v2014102117\tools\ant.
- Add it to the path statement: ;%ANT_HOME%/bin.
In Eclipse
- In Eclipse, navigate to: Windows > Preferences > Ant > Runtime.
- Click Ant Home….
- Navigate to C:\opt\eclipseplugins\com.oxygenxml.editor_16.1.0.v2014102117\tools\ant.
- Click Ok, then click Apply, and then click OK.
Update the Ant installation with the latest libraries and dependencies
Open a command prompt window (with Administrative privileges), and execute the following command:
ant -f fetch.xml -Ddest=system
Note: ant.bat is the batch file that serves as the wrapper script for Windows.
Ant script structure
Ant scripts have the following structure:
<Project>
<Target>
<Task>
</Task>
</Target>
</Project>
Doc build timestamp
I wanted each doc build to include the time that I generated the docs. For more information, see the documentation for tstamp. To accomplish this, you use the TODAY property in your Ant project, but first you need to initialize it. You do this by adding the following statement to your Ant project.
<tstamp/>
This sets the standard DSTAMP, TSTAMP, and TODAY properties according to the default formats. I added it to the init target to make its use obvious.
<target name="init" description="Ant build project setup.">
<tstamp>
<format property="doc_build.time_stamp" pattern="EEEE MMMM dd, yyyy 'at' h:mm:ss a z" />
</tstamp>
</target>
Notice that I created my own property called doc_build.time_stamp.
Usage
I use my new doc build timestamp property inside the target that I created for building the HTML docs.
<property name="javadoc.footer" value="<strong>Built:</strong>	${doc_build.time_stamp}." />
build.xml
build.xml is the default name used by Ant for the Ant project file.
My build.xml
Here’s the XML in my build.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<project name="3rdParty Mobile SDK" default="HTML Docs" basedir=".">
<property name="src.dir" value="${basedir}/src"/>
<property name="dest.dir" value="${basedir}/doc"/>
<property name="lib.dir" value="${basedir}/lib"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>
<target name="init" description="Ant build project setup.">
<tstamp>
<format property="doc_build.time_stamp" pattern="EEEE MMMM dd, yyyy 'at' h:mm:ss a z" />
</tstamp>
</target>
<target name="HTML Docs" depends="init" description="Compile the HTML version of the docs.">
<property name="javadoc.header" value="<strong>3rdParty Mobile SDK</strong>	v1.0" />
<property name="javadoc.footer" value="<strong>Built:</strong>	${doc_build.time_stamp}." />
<property name="javadoc.bottom" value='Copyright &copy; 2013 - <script> var currYear=new Date(); document.write(currYear.getFullYear()); </script>, 3rdParty Corp., All rights reserved.' />
<javadoc
classpath="${basedir}/libs/android-support-v4.jar;C:\Android\sdk\platforms\android-19\android.jar"
access="public"
additionalparam=" -noqualifier java.lang:java.io "
author="true"
destdir="${dest.dir}"
doctitle="3rdParty Mobile SDK Documentation"
windowtitle="3rdParty Mobile SDK for Android"
nodeprecated="true"
nodeprecatedlist="true"
noindex="false"
nonavbar="false"
notree="false"
overview="${basedir}/overview.html"
packagenames="com.3rdPartymobilesdk"
source="7"
sourcepath="${src.dir}"
splitindex="true"
use="true"
version="true">
<link href="http://download.oracle.com/javase/7/docs/api/"/>
<header><![CDATA[${javadoc.header}]]></header>
<footer><![CDATA[${javadoc.footer}]]></footer>
<bottom><![CDATA[${javadoc.bottom}]]></bottom>
</javadoc>
</target>
</project>