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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 2018"><meta name="DC.rights.owner" content="(C) Copyright 2018"><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="../topics/publishing-with-ant.html"><meta name="DC.Relation" scheme="URI" content="../topics/migrating-ant-to-dita.html"><meta name="DC.Relation" scheme="URI" content="../topics/building-with-ant.html"><meta name="DC.Relation" scheme="URI" content="../topics/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="HTML5"><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 3.0</a></li><li><a href="../release-notes/index.html">Release Notes</a></li><li><a href="../topics/installing-client.html">Installing DITA-OT</a></li><li><a href="../topics/alternative-input-formats.html">Authoring formats</a></li><li><a href="../topics/building-output.html">Building output</a><ul><li><a href="../topics/build-using-dita-command.html">Using the dita command</a></li><li><a href="../topics/publishing-with-ant.html">Using Ant</a><ul><li><a href="../topics/ant.html">Ant</a></li><li><a href="../topics/building-with-ant.html">Building output using Ant</a></li><li class="active"><a href="../topics/creating-an-ant-build-script.html">Creating an Ant build script</a></li></ul></li><li><a href="../topics/output-formats.html">Output formats</a></li></ul></li><li><a href="../parameters/index.html">Setting parameters</a></li><li><a href="../topics/extending-the-ot.html">Customizing DITA-OT</a></li><li><a href="../topics/troubleshooting-overview.html">Troubleshooting</a></li><li><a href="../reference/index.html">Reference</a></li><li><a href="../topics/dita-and-dita-ot-resources.html">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;/ant&gt;
  73. &lt;/target&gt;
  74. &lt;target name="pdf" description="build PDF"&gt;
  75. &lt;ant antfile="${dita.dir}/build.xml"&gt;
  76. &lt;property name="args.input" location="../taskbook.ditamap"/&gt;
  77. &lt;property name="transtype" value="pdf"/&gt;
  78. &lt;property name="output.dir" location="../out/pdf"/&gt;
  79. &lt;property name="args.gen.task.lbl" value="YES"/&gt;
  80. &lt;property name="args.rellinks" value="nofamily"/&gt;
  81. &lt;/ant&gt;
  82. &lt;/target&gt;
  83. &lt;/project&gt;</code></pre></div>
  84. <div class="p">In addition to the mandatory parameters (<span class="keyword parmname">args.input</span> and <span class="keyword parmname">transtype</span>),
  85. the chm and pdf targets each specify some optional parameters:
  86. <ul class="ul">
  87. <li class="li">The <span class="keyword parmname">args.gen.task.lbl</span> property is set to YES, which ensures that headings are
  88. automatically generated for the sections of task topics.</li>
  89. <li class="li">The <span class="keyword parmname">output.dir</span> property specifies where the DITA-OT writes the output of the
  90. transformations.</li>
  91. </ul></div>
  92. <p class="p">The pdf target also specifies that related links should be generated in the PDF, but only
  93. those links that are created by relationship tables and <code class="keyword markupname xmlelement">&lt;link&gt;</code>
  94. elements.</p>
  95. <p class="p">Finally, the all target simply specifies that both the chm and pdf target should be run.</p>
  96. </div>
  97. <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_sample/</span>
  98. directory. This directory contains sample Ant build files for common output formats, as well as
  99. templates that you can use to create your own Ant scripts.</section>
  100. </div>
  101. <nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/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.">Building output using Ant</a></div></div><div class="linklist relinfo relconcepts"><strong>Related concepts</strong><br><ul class="linklist"><li class="linklist"><a class="link" href="../topics/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></li></ul></div><div class="linklist relinfo reltasks"><strong>Related tasks</strong><br><ul class="linklist"><li class="linklist"><a class="link" href="../topics/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></li><li class="linklist"><a class="link" href="../topics/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></li></ul></div><div class="linklist relinfo relref"><strong>Related reference</strong><br><ul class="linklist"><li class="linklist"><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 --parameter=value syntax or included in build scripts as Ant properties.">DITA-OT parameters</a></li><li class="linklist"><a class="link" href="http://ant.apache.org/manual" target="_blank">Apache Ant documentation</a></li></ul></div></nav></article></main></body></html>