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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 2019"><meta name="DC.rights.owner" content="(C) Copyright 2019"><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.subject" content=", link, name, default, Ant, build script, relationship tables, PDF"><meta name="keywords" content=", link, name, default, Ant, build script, relationship tables, PDF"><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.3</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="../reference/java-api.html">Using the Java API</a></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/customizing.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. <section><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 language-xml normalize-space show-line-numbers show-whitespace"><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 project.</span>
  31. </li>
  32. <li class="li substep substepexpand">
  33. <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
  34. script.</span>
  35. <div class="itemgroup info">If the build script is invoked without specifying a target, this target will be run.</div>
  36. </li>
  37. </ol>
  38. </li><li class="li step stepexpand">
  39. <span class="ph cmd">Set the value of the <span class="keyword parmname">dita.dir</span> property to the location of the DITA-OT
  40. installation.</span>
  41. <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
  42. that you are writing. </div>
  43. </li><li class="li step stepexpand">
  44. <span class="ph cmd">Create the Ant target:</span>
  45. <ol type="a" class="ol substeps">
  46. <li class="li substep">
  47. <span class="ph cmd">Set the value of the <code class="keyword markupname xmlatt">@name</code> attribute.</span>
  48. </li>
  49. <li class="li substep">
  50. <span class="ph cmd">Specify the value for the <span class="keyword parmname">args.input</span> property.</span>
  51. </li>
  52. <li class="li substep">
  53. <span class="ph cmd">Specify the value of the <span class="keyword parmname">transtype</span> property.</span>
  54. </li>
  55. </ol>
  56. </li><li class="li step stepexpand">
  57. <span class="ph cmd">Save the build script.</span>
  58. </li></ol></section>
  59. <section class="example"><div class="tasklabel"><h2 class="sectiontitle tasklabel">Example</h2></div>
  60. <p class="p">The following Ant build script generates CHM and PDF output for the sample DITA maps.</p>
  61. <div class="p">
  62. <pre class="pre codeblock language-xml normalize-space show-line-numbers show-whitespace"><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 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 those links that are
  93. created by relationship tables and <code class="keyword markupname xmlelement">&lt;link&gt;</code> elements.</p>
  94. <p class="p">Finally, the all target simply specifies that both the chm and pdf target should be run.</p>
  95. </section>
  96. <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> directory. This
  97. directory contains sample Ant build files for common output formats, as well as templates that you can use to
  98. create your own Ant scripts.</section>
  99. </div>
  100. <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 DITA Open Toolkit and generate output. You can use the complete set of parameters that the toolkit supports.">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 DITA Open Toolkit still supports Ant builds, switching to the dita command offers a simpler command interface, sets all required environment variables and allows you to run DITA-OT without setting up anything beforehand.">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>