creating-an-ant-build-script.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!DOCTYPE html
  2. SYSTEM "about:legacy-compat">
  3. <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">
  4. <p>DITA Open Toolkit</p>
  5. <hr>
  6. </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">
  7. <h1 class="title topictitle1" id="ariaid-title1">Creating an Ant build script</h1>
  8. <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
  9. script that contains all of the parameters.</p>
  10. <div class="tasklabel"><h2 class="sectiontitle tasklabel">Procedure</h2></div><ol class="ol steps"><li class="li step stepexpand">
  11. <span class="ph cmd">Create an XML file that contains the following content:</span>
  12. <div class="itemgroup info">
  13. <pre class="pre codeblock"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  14. &lt;project name="%project-name%" default="%default-target%" basedir="."&gt;
  15. &lt;property name="dita.dir" location="%path-to-DITA-OT%"/&gt;
  16. &lt;target name="%target-name%"&gt;
  17. &lt;ant antfile="${dita.dir}/build.xml"&gt;
  18. &lt;property name="args.input" value="%DITA-input%"/&gt;
  19. &lt;property name="transtype" value="html5"/&gt;
  20. &lt;/ant&gt;
  21. &lt;/target&gt;
  22. &lt;/project&gt;</code></pre>
  23. </div>
  24. <div class="itemgroup info">You will replace the placeholder content (indicated by the % signs) with content applicable to your
  25. environment.</div>
  26. </li><li class="li step stepexpand">
  27. <span class="ph cmd">Specify project information:</span>
  28. <ol type="a" class="ol substeps">
  29. <li class="li substep substepexpand"><strong>Optional: </strong>
  30. <span class="ph cmd">Set the value of the <code class="keyword markupname xmlatt">@name</code> attribute to the name of your
  31. project.</span>
  32. </li>
  33. <li class="li substep substepexpand">
  34. <span class="ph cmd">Set the value of the <code class="keyword markupname xmlatt">@default</code> attribute to the name of a target in
  35. the build script.</span>
  36. <div class="itemgroup info">If the build script is invoked without specifying a target, this target will be
  37. run.</div>
  38. </li>
  39. </ol>
  40. </li><li class="li step stepexpand">
  41. <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>
  42. <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
  43. that you are writing. </div>
  44. </li><li class="li step stepexpand">
  45. <span class="ph cmd">Create the Ant target:</span>
  46. <ol type="a" class="ol substeps">
  47. <li class="li substep">
  48. <span class="ph cmd">Set the value of the <code class="keyword markupname xmlatt">@name</code> attribute.</span>
  49. </li>
  50. <li class="li substep">
  51. <span class="ph cmd">Specify the value for the <span class="keyword parmname">args.input</span> property.</span>
  52. </li>
  53. <li class="li substep">
  54. <span class="ph cmd">Specify the value of the <span class="keyword parmname">transtype</span> property.</span>
  55. </li>
  56. </ol>
  57. </li><li class="li step stepexpand">
  58. <span class="ph cmd">Save the build script.</span>
  59. </li></ol>
  60. <div class="example"><div class="tasklabel"><h2 class="sectiontitle tasklabel">Example</h2></div>
  61. <div class="p">The following Ant build script generates CHM and PDF output for the sample DITA
  62. maps.<pre class="pre codeblock"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  63. &lt;project name="build-chm-pdf" default="all" basedir="."&gt;
  64. &lt;property name="dita.dir" location="${basedir}/../../.."/&gt;
  65. &lt;target name="all" description="build CHM and PDF" depends="chm,pdf"/&gt;
  66. &lt;target name="chm" description="build CHM"&gt;
  67. &lt;ant antfile="${dita.dir}/build.xml"&gt;
  68. &lt;property name="args.input" location="../sequence.ditamap"/&gt;
  69. &lt;property name="transtype" value="htmlhelp"/&gt;
  70. &lt;property name="output.dir" location="../out/chm"/&gt;
  71. &lt;property name="args.gen.task.lbl" value="YES"/&gt;
  72. &lt;property name="args.breadcrumbs" value="yes"/&gt;
  73. &lt;/ant&gt;
  74. &lt;/target&gt;
  75. &lt;target name="pdf" description="build PDF"&gt;
  76. &lt;ant antfile="${dita.dir}/build.xml"&gt;
  77. &lt;property name="args.input" location="../taskbook.ditamap"/&gt;
  78. &lt;property name="transtype" value="pdf"/&gt;
  79. &lt;property name="output.dir" location="../out/pdf"/&gt;
  80. &lt;property name="args.gen.task.lbl" value="YES"/&gt;
  81. &lt;property name="args.rellinks" value="nofamily"/&gt;
  82. &lt;/ant&gt;
  83. &lt;/target&gt;
  84. &lt;/project&gt;</code></pre></div>
  85. <div class="p">In addition to the mandatory parameters (<span class="keyword parmname">args.input</span> and <span class="keyword parmname">transtype</span>),
  86. the chm and pdf targets each specify some optional parameters:
  87. <ul class="ul">
  88. <li class="li">The <span class="keyword parmname">args.gen.task.lbl</span> property is set to YES, which ensures that headings are
  89. automatically generated for the sections of task topics.</li>
  90. <li class="li">The <span class="keyword parmname">output.dir</span> property specifies where the DITA-OT writes the output of the
  91. transformations.</li>
  92. </ul></div>
  93. <p class="p">The pdf target also specifies that related links should be generated in the PDF, but only
  94. those links that are created by relationship tables and <code class="keyword markupname xmlelement">&lt;link&gt;</code>
  95. elements.</p>
  96. <p class="p">Finally, the all target simply specifies that both the chm and pdf target should be run.</p>
  97. </div>
  98. <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>
  99. directory. This directory contains the Ant build files used by the demo build, as well as
  100. templates that you can use to create Ant scripts.</section>
  101. </div>
  102. <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>