1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 | <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
|
---|
3 | <task id="creating-an-ant-build-script">
|
---|
4 | <title>Creating an Ant build script</title>
|
---|
5 | <shortdesc>Instead of typing the DITA-OT parameters at the command prompt, you might want to
|
---|
6 | create an Ant build script that contains all of the parameters.</shortdesc>
|
---|
7 | <taskbody>
|
---|
8 | <steps>
|
---|
9 | <step>
|
---|
10 | <cmd>Create an XML file that contains the following content:</cmd>
|
---|
11 | <info>
|
---|
12 | <codeblock><?xml version="1.0" encoding="UTF-8" ?>
|
---|
13 | <project name="@project-name@" default="@default-target@" basedir=".">
|
---|
14 |
|
---|
15 | <property name="dita.dir" location="@path-to-DITA-OT@"/>
|
---|
16 |
|
---|
17 | <target name="@target-name@">
|
---|
18 | <ant antfile="${dita.dir}${file.separator}build.xml">
|
---|
19 | <property name="args.input" value="@DITA-input@"/>
|
---|
20 | <property name="transtype" value="xhtml"/>
|
---|
21 | </ant>
|
---|
22 | </target>
|
---|
23 |
|
---|
24 | </project></codeblock>
|
---|
25 | </info>
|
---|
26 | <info>You will replace the placeholder content (indicated by the @ signs) with
|
---|
27 | content applicable to your environment.</info>
|
---|
28 | </step>
|
---|
29 | <step>
|
---|
30 | <cmd>Specify project information:</cmd>
|
---|
31 | <substeps>
|
---|
32 | <substep>
|
---|
33 | <cmd>Set the value of the @name attribute to X.<draft-comment
|
---|
34 | author="Kristen James Eberlein" time="11 August 2012">What does X
|
---|
35 | need to be? Does it really matter? I tend to set this attribute to
|
---|
36 | the string that I use for the name of the Ant
|
---|
37 | script.</draft-comment></cmd>
|
---|
38 | </substep>
|
---|
39 | <substep>
|
---|
40 | <cmd>Set the value of the @default attribute to the name of a target in the
|
---|
41 | build script.</cmd>
|
---|
42 | <info>If the build script is invoked without specifying a target, this
|
---|
43 | target will be run.</info>
|
---|
44 | </substep>
|
---|
45 | </substeps>
|
---|
46 | </step>
|
---|
47 | <step>
|
---|
48 | <cmd>Set the value of the <parmname>dita.dir</parmname> property to the location of
|
---|
49 | the DITA-OT.</cmd>
|
---|
50 | <info>This can be a fully qualified path, or you can specify it relative to the
|
---|
51 | location of the Ant build script that you are writing. </info>
|
---|
52 | </step>
|
---|
53 | <step>
|
---|
54 | <cmd>Create the Ant target:</cmd>
|
---|
55 | <substeps>
|
---|
56 | <substep>
|
---|
57 | <cmd>Set the value of the @name attribute.</cmd>
|
---|
58 | </substep>
|
---|
59 | <substep>
|
---|
60 | <cmd>Specify the value for the <parmname>args.input</parmname>
|
---|
61 | property.</cmd>
|
---|
62 | </substep>
|
---|
63 | <substep>
|
---|
64 | <cmd>Specify the value of the <parmname>transtype</parmname> property.</cmd>
|
---|
65 | </substep>
|
---|
66 | </substeps>
|
---|
67 | </step>
|
---|
68 | <step>
|
---|
69 | <cmd>Save the build script.</cmd>
|
---|
70 | </step>
|
---|
71 | </steps>
|
---|
72 | <example>
|
---|
73 | <p>The following Ant build script generates CHM and PDF output for the
|
---|
74 | <filepath>userguide.ditamap</filepath>
|
---|
75 | file.<codeblock><?xml version="1.0" encoding="UTF-8" ?>
|
---|
76 | <project name="Toolkit-documentation" default="all" basedir=".">
|
---|
77 |
|
---|
78 | <property name="dita.dir" location="C:\DITA-OT1.6.M5"/>
|
---|
79 |
|
---|
80 | <target name="all" description="build CHM and PDF" depends="chm,pdf"/>
|
---|
81 |
|
---|
82 | <target name="chm" description="build CHM">
|
---|
83 | <ant antfile="${dita.dir}\build.xml">
|
---|
84 | <property name="args.input" value="C:\dita-ot\src\main\doc\userguide.ditamap"/>
|
---|
85 | <property name="args.gen.task.lbl" value="YES"/>
|
---|
86 | <property name="output.dir" value="C:\kje\temp\out"/>
|
---|
87 | <property name="transtype" value="htmlhelp"/>
|
---|
88 | </ant>
|
---|
89 | </target>
|
---|
90 |
|
---|
91 | <target name="pdf" description="build PDF">
|
---|
92 | <ant antfile="${dita.dir}\build.xml">
|
---|
93 | <property name="args.input" value="C:\dita-ot\src\main\doc\userguide.ditamap"/>
|
---|
94 | <property name="args.gen.task.lbl" value="YES"/>
|
---|
95 | <property name="args.rellinks" value="nofamily"/>
|
---|
96 | <property name="output.dir" value="C:\kje\temp\out"/>
|
---|
97 | <property name="transtype" value="pdf"/>
|
---|
98 | </ant>
|
---|
99 | </target>
|
---|
100 |
|
---|
101 | </project></codeblock></p>
|
---|
102 | <p>In addition to the mandatory parameters (<parmname>args.input</parmname> and
|
---|
103 | <parmname>transtype</parmname>), the chm and pdf targets each specify some
|
---|
104 | optional parameters:<ul>
|
---|
105 | <li>The <parmname>args.gen.task.lbl</parmname> property is set to YES, which
|
---|
106 | ensures that headings are automatically generated for the sections of task
|
---|
107 | topics.</li>
|
---|
108 | <li>The <parmname>output.dir</parmname> property specifies where the DITA OT
|
---|
109 | writes the output of the transformations.</li>
|
---|
110 | </ul></p>
|
---|
111 | <p>The pdf target also specifies that related links should be generated in the PDF, but
|
---|
112 | only those links that are created by relationship tables and <link> elements.</p>
|
---|
113 | <p>Finally, the all target simply specifies that both the chm and pdf target should be
|
---|
114 | run.</p>
|
---|
115 | </example>
|
---|
116 | <postreq>Another resource for learning about Ant scripts are the files in the
|
---|
117 | <filepath>samples/ant_samples</filepath> directory. This directory contains the Ant
|
---|
118 | build files used by the demo build, as well as templates that you can use to create Ant
|
---|
119 | scripts.</postreq>
|
---|
120 | </taskbody>
|
---|
121 | </task>
|
---|