| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <!DOCTYPE html
- SYSTEM "about:legacy-compat">
- <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2016"><meta name="DC.rights.owner" content="(C) Copyright 2016"><meta name="DC.Type" content="task"><meta name="description" content="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."><meta name="DC.Relation" scheme="URI" content="../user-guide/publishing-with-ant.html"><meta name="DC.Relation" scheme="URI" content="../user-guide/build-migrating-ant-to-dita.html"><meta name="DC.Relation" scheme="URI" content="../user-guide/building-with-ant.html"><meta name="DC.Relation" scheme="URI" content="../user-guide/ant.html"><meta name="DC.Relation" scheme="URI" content="../parameters/parameters_intro.html"><meta name="DC.Relation" scheme="URI" content="http://ant.apache.org/manual"><meta name="DC.Format" content="XHTML"><meta name="DC.Identifier" content="creating-an-ant-build-script"><link rel="stylesheet" type="text/css" href="../css/commonltr.css"><link rel="stylesheet" type="text/css" href="../css/dita-ot-doc.css"><title>Creating an Ant build script</title></head><body id="creating-an-ant-build-script"><header role="banner"><div class="header">
- <p>DITA Open Toolkit</p>
- <hr>
- </div></header><nav role="toc"><ul><li><a href="../index.html">DITA Open Toolkit 2.3</a></li><li><a href="../release-notes/index.html">Release Notes</a></li><li><a href="../getting-started/index.html">Getting Started</a></li><li><a href="../user-guide/index.html">User Guide</a><ul><li><a href="../user-guide/transforming-dita-content.html">Publishing DITA content</a><ul><li><a href="../user-guide/build-using-dita-command.html">Using the dita command</a></li><li><a href="../user-guide/publishing-with-ant.html">Using Ant</a><ul><li><a href="../user-guide/ant.html">Ant overview</a></li><li><a href="../user-guide/building-with-ant.html">Building output using Ant</a></li><li class="active"><a href="../user-guide/creating-an-ant-build-script.html">Creating an Ant build script</a></li></ul></li></ul></li><li><a href="../user-guide/AvailableTransforms.html">Output formats</a></li><li><a href="../user-guide/DITA_spec-support.html">DITA specification support</a></li><li><a href="../user-guide/DITA-globalization.html">Globalizing DITA content</a></li><li><a href="../user-guide/troubleshooting-overview.html">Troubleshooting</a></li></ul></li><li><a href="../parameters/index.html">Parameter Reference</a></li><li><a href="../dev_ref/index.html">Developer Reference</a></li><li><a href="../user-guide/dita-and-dita-ot-resources.html">DITA Resources</a></li></ul></nav><main role="main"><article role="article" aria-labelledby="ariaid-title1">
- <h1 class="title topictitle1" id="ariaid-title1">Creating an Ant build script</h1>
-
- <div class="body taskbody"><p class="shortdesc">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.</p>
- <div class="tasklabel"><h2 class="sectiontitle tasklabel">Procedure</h2></div><ol class="ol steps"><li class="li step stepexpand">
- <span class="ph cmd">Create an XML file that contains the following content:</span>
- <div class="itemgroup info">
- <pre class="pre codeblock"><code><?xml version="1.0" encoding="UTF-8" ?>
- <project name="%project-name%" default="%default-target%" basedir=".">
- <property name="dita.dir" location="%path-to-DITA-OT%"/>
-
- <target name="%target-name%">
- <ant antfile="${dita.dir}/build.xml">
- <property name="args.input" value="%DITA-input%"/>
- <property name="transtype" value="html5"/>
- </ant>
- </target>
- </project></code></pre>
- </div>
- <div class="itemgroup info">You will replace the placeholder content (indicated by the % signs) with content applicable to your
- environment.</div>
- </li><li class="li step stepexpand">
- <span class="ph cmd">Specify project information:</span>
- <ol type="a" class="ol substeps">
- <li class="li substep substepexpand"><strong>Optional: </strong>
- <span class="ph cmd">Set the value of the <code class="keyword markupname xmlatt">@name</code> attribute to the name of your
- project.</span>
- </li>
- <li class="li substep substepexpand">
- <span class="ph cmd">Set the value of the <code class="keyword markupname xmlatt">@default</code> attribute to the name of a target in
- the build script.</span>
- <div class="itemgroup info">If the build script is invoked without specifying a target, this target will be
- run.</div>
- </li>
- </ol>
- </li><li class="li step stepexpand">
- <span class="ph cmd">Set the value of the <span class="keyword parmname">dita.dir</span> property to the location of the DITA-OT.</span>
- <div class="itemgroup info">This can be a fully qualified path, or you can specify it relative to the location of the Ant build script
- that you are writing. </div>
- </li><li class="li step stepexpand">
- <span class="ph cmd">Create the Ant target:</span>
- <ol type="a" class="ol substeps">
- <li class="li substep">
- <span class="ph cmd">Set the value of the <code class="keyword markupname xmlatt">@name</code> attribute.</span>
- </li>
- <li class="li substep">
- <span class="ph cmd">Specify the value for the <span class="keyword parmname">args.input</span> property.</span>
- </li>
- <li class="li substep">
- <span class="ph cmd">Specify the value of the <span class="keyword parmname">transtype</span> property.</span>
- </li>
- </ol>
- </li><li class="li step stepexpand">
- <span class="ph cmd">Save the build script.</span>
- </li></ol>
- <div class="example"><div class="tasklabel"><h2 class="sectiontitle tasklabel">Example</h2></div>
- <div class="p">The following Ant build script generates CHM and PDF output for the sample DITA
- maps.<pre class="pre codeblock"><code><?xml version="1.0" encoding="UTF-8" ?>
- <project name="build-chm-pdf" default="all" basedir=".">
- <property name="dita.dir" location="${basedir}/../../.."/>
- <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" location="../sequence.ditamap"/>
- <property name="transtype" value="htmlhelp"/>
- <property name="output.dir" location="../out/chm"/>
- <property name="args.gen.task.lbl" value="YES"/>
- <property name="args.breadcrumbs" value="yes"/>
- </ant>
- </target>
- <target name="pdf" description="build PDF">
- <ant antfile="${dita.dir}/build.xml">
- <property name="args.input" location="../taskbook.ditamap"/>
- <property name="transtype" value="pdf"/>
- <property name="output.dir" location="../out/pdf"/>
- <property name="args.gen.task.lbl" value="YES"/>
- <property name="args.rellinks" value="nofamily"/>
- </ant>
- </target>
- </project></code></pre></div>
- <div class="p">In addition to the mandatory parameters (<span class="keyword parmname">args.input</span> and <span class="keyword parmname">transtype</span>),
- the chm and pdf targets each specify some optional parameters:
- <ul class="ul">
- <li class="li">The <span class="keyword parmname">args.gen.task.lbl</span> property is set to YES, which ensures that headings are
- automatically generated for the sections of task topics.</li>
- <li class="li">The <span class="keyword parmname">output.dir</span> property specifies where the DITA-OT writes the output of the
- transformations.</li>
- </ul></div>
- <p class="p">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 <code class="keyword markupname xmlelement"><link></code>
- elements.</p>
- <p class="p">Finally, the all target simply specifies that both the chm and pdf target should be run.</p>
- </div>
- <section class="section postreq"><div class="tasklabel"><h2 class="sectiontitle tasklabel">What to do next</h2></div>Another resource for learning about Ant scripts are the files in the <span class="ph filepath"><var class="keyword varname">dita-ot-dir</var>/docsrc/samples</span><span class="ph filepath">/ant_samples</span>
- 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.</section>
- </div>
- <nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../user-guide/publishing-with-ant.html" title="You can use Ant to invoke the DITA Open Toolkit and generate output. You can use the complete set of parameters that are supported by the toolkit.">Publishing DITA content from Ant</a></div></div><div class="linklist linklist relinfo relconcepts"><strong>Related concepts</strong><br><div><a class="link" href="../user-guide/ant.html" title="Ant is a Java-based, open-source tool that is provided by the Apache Foundation. It can be used to declare a sequence of build actions. It is well suited for both development and document builds. The toolkit ships with a copy of Ant.">Ant</a></div></div><div class="linklist linklist relinfo reltasks"><strong>Related tasks</strong><br><div><a class="link" href="../user-guide/building-with-ant.html" title="You can build output by using an Ant build script to provide the DITA-OT parameters.">Building output using Ant</a></div><div><a class="link" href="../user-guide/build-migrating-ant-to-dita.html" title="Although Ant builds are still supported in the DITA Open Toolkit, you might want to switch to use the new dita command.">Migrating Ant builds to use the dita command</a></div></div><div class="linklist linklist relinfo relref"><strong>Related reference</strong><br><div><a class="link" href="../parameters/parameters_intro.html" title="Certain parameters apply to all DITA-OT transformations. Other parameters are common to the HTML-based transformations. Some parameters apply only to specific transformation types. These parameters can be passed as options to the dita command using the -Dparameter-name=value syntax or included in build scripts as Ant properties.">DITA-OT parameters</a></div><div><a class="link" href="http://ant.apache.org/manual" target="_blank">Apache Ant documentation</a></div></div></nav></article></main></body></html>
|