Writing Ant Build Files DITA-OT

Learning how buildfiles tell Ant what and how to compile.

Customize the Default Ant Script

The sample Ant build scripts provided by the DITA-OT may not be adequate to meet the needs of your documentation project. This topic describes how to customize the default scripts and write your own.

The DITA Open Toolkit contains sample build files for both the DITA-OT and sample documentation. Writers new to the toolkit use the sample_all.xml Ant build script to create all the sample documents that come with DITA-OT. The toolkit also contains build scripts for individual ouput types, such as sample_pdf.xml. You can modify just one or two Ant properties in these scripts for your own documentation.

Here is the Ant project definition from template_pdf.xml

You simply change the values of the following properties to match the values used in your project:
  • Project name: The root element in an Ant build file.
  • Target name: Must be one of the DITA-OT targets listed in Ant Properties for DITA-OT
However, the toolkit's scripts assume that your input files are located in same directory structure used by the DITA-OT samples.

Write Your Own Ant Script

The default build script may not meet the needs of your project for a range of reasons:

You need to cutomize or write your own build file for these use cases. For example, each target for this guide's build script uses a separate value for dita.temp.dir to assist debugging for a specific output types.

Here is the beginning of the ant script that produced this document:

Ant Properties for DITA-OT contains a short list of the most basic Ant properties used by DITA-OT. Use these properties to customize your document's build script for your needs.