creating-an-ant-build-script.dita 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <task id="creating-an-ant-build-script">
  5. <title>Creating an Ant build script</title>
  6. <shortdesc>Instead of typing the DITA-OT parameters at the command prompt, you might want to create an Ant build
  7. script that contains all of the parameters.</shortdesc>
  8. <prolog>
  9. <metadata>
  10. <keywords>
  11. <indexterm><xmlelement>link</xmlelement></indexterm>
  12. <indexterm><xmlatt>name</xmlatt></indexterm>
  13. <indexterm><xmlatt>default</xmlatt></indexterm>
  14. <indexterm>Ant<indexterm>build script</indexterm></indexterm>
  15. <indexterm>relationship tables<indexterm>PDF</indexterm></indexterm>
  16. </keywords>
  17. </metadata>
  18. </prolog>
  19. <taskbody>
  20. <steps>
  21. <step>
  22. <cmd>Create an XML file that contains the following content:</cmd>
  23. <info>
  24. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;?xml version="1.0" encoding="UTF-8" ?>
  25. &lt;project name="%project-name%" default="%default-target%" basedir=".">
  26. &lt;property name="dita.dir" location="%path-to-DITA-OT%"/>
  27. &lt;target name="%target-name%">
  28. &lt;ant antfile="${dita.dir}/build.xml">
  29. &lt;property name="args.input" value="%DITA-input%"/>
  30. &lt;property name="transtype" value="html5"/>
  31. &lt;/ant>
  32. &lt;/target>
  33. &lt;/project></codeblock>
  34. </info>
  35. <info>You will replace the placeholder content (indicated by the % signs) with content applicable to your
  36. environment.</info>
  37. </step>
  38. <step>
  39. <cmd>Specify project information:</cmd>
  40. <substeps>
  41. <substep importance="optional">
  42. <cmd>Set the value of the <xmlatt>name</xmlatt> attribute to the name of your project.</cmd>
  43. </substep>
  44. <substep>
  45. <cmd>Set the value of the <xmlatt>default</xmlatt> attribute to the name of a target in the build
  46. script.</cmd>
  47. <info>If the build script is invoked without specifying a target, this target will be run.</info>
  48. </substep>
  49. </substeps>
  50. </step>
  51. <step>
  52. <cmd>Set the value of the <parmname>dita.dir</parmname> property to the location of the DITA-OT
  53. installation.</cmd>
  54. <info>This can be a fully qualified path, or you can specify it relative to the location of the Ant build script
  55. that you are writing. </info>
  56. </step>
  57. <step>
  58. <cmd>Create the Ant target:</cmd>
  59. <substeps>
  60. <substep>
  61. <cmd>Set the value of the <xmlatt>name</xmlatt> attribute.</cmd>
  62. </substep>
  63. <substep>
  64. <cmd>Specify the value for the <parmname>args.input</parmname> property.</cmd>
  65. </substep>
  66. <substep>
  67. <cmd>Specify the value of the <parmname>transtype</parmname> property.</cmd>
  68. </substep>
  69. </substeps>
  70. </step>
  71. <step>
  72. <cmd>Save the build script.</cmd>
  73. </step>
  74. </steps>
  75. <example>
  76. <p>The following Ant build script generates CHM and PDF output for the sample DITA maps.</p>
  77. <p>
  78. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace"><coderef href="../samples/ant_sample/build-chm-pdf.xml"/></codeblock></p>
  79. <p>In addition to the mandatory parameters (<parmname>args.input</parmname> and <parmname>transtype</parmname>),
  80. the chm and pdf targets each specify some optional parameters:
  81. <ul>
  82. <li>The <parmname>args.gen.task.lbl</parmname> property is set to YES, which ensures that headings are
  83. automatically generated for the sections of task topics.</li>
  84. <li>The <parmname>output.dir</parmname> property specifies where DITA-OT writes the output of the
  85. transformations.</li>
  86. </ul></p>
  87. <p>The pdf target also specifies that related links should be generated in the PDF, but only those links that are
  88. created by relationship tables and <xmlelement>link</xmlelement> elements.</p>
  89. <p>Finally, the all target simply specifies that both the chm and pdf target should be run.</p>
  90. </example>
  91. <postreq>Another resource for learning about Ant scripts are the files in the <filepath
  92. conref="../resources/conref-task.dita#ID/samples-dir"/><filepath>/ant_sample/</filepath> directory. This
  93. directory contains sample Ant build files for common output formats, as well as templates that you can use to
  94. create your own Ant scripts.</postreq>
  95. </taskbody>
  96. </task>