Creating an Ant build script

DITA Open Toolkit

Creating an Ant build script

Instead of typing the DITA-OT parameters at the command prompt, you might want to create an Ant build script that contains all of the parameters.

Procedure

Example

The following Ant build script generates CHM and PDF output for the userguide.ditamap file.
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Toolkit-documentation" default="all" basedir=".">
    
    <property name="dita.dir" location="C:\DITA-OT1.6.M5"/>
    
    <target name="all" description="build CHM and PDF" depends="chm,pdf"/>
    
    <target name="chm" description="build CHM">
        <ant antfile="${dita.dir}\build.xml">
            <property name="args.input" value="C:\dita-ot\src\main\doc\userguide.ditamap"/>
            <property name="args.gen.task.lbl" value="YES"/>   
            <property name="output.dir" value="C:\kje\temp\out"/>
            <property name="transtype" value="htmlhelp"/>
        </ant>
    </target>
    
    <target name="pdf" description="build PDF">
        <ant antfile="${dita.dir}\build.xml">
            <property name="args.input" value="C:\dita-ot\src\main\doc\userguide.ditamap"/>
            <property name="args.gen.task.lbl" value="YES"/>   
            <property name="args.rellinks" value="nofamily"/>   
            <property name="output.dir" value="C:\kje\temp\out"/>
            <property name="transtype" value="pdf"/>
        </ant>
    </target>
    
</project>
In addition to the mandatory parameters (args.input and transtype), the chm and pdf targets each specify some optional parameters:
  • The args.gen.task.lbl property is set to YES, which ensures that headings are automatically generated for the sections of task topics.
  • The output.dir property specifies where the DITA OT writes the output of the transformations.

The pdf target also specifies that related links should be generated in the PDF, but only those links that are created by relationship tables and <link> elements.

Finally, the all target simply specifies that both the chm and pdf target should be run.

What to do next

Another resource for learning about Ant scripts are the files in the samples/ant_samples directory. This directory contains the Ant build files used by the demo build, as well as templates that you can use to create Ant scripts.
Related concepts