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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.md file for applicable licenses.-->
  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. <taskbody>
  9. <steps>
  10. <step>
  11. <cmd>Create an XML file that contains the following content:</cmd>
  12. <info>
  13. <codeblock>&lt;?xml version="1.0" encoding="UTF-8" ?>
  14. &lt;project name="%project-name%" default="%default-target%" basedir=".">
  15. &lt;property name="dita.dir" location="%path-to-DITA-OT%"/>
  16. &lt;target name="%target-name%">
  17. &lt;ant antfile="${dita.dir}/build.xml">
  18. &lt;property name="args.input" value="%DITA-input%"/>
  19. &lt;property name="transtype" value="html5"/>
  20. &lt;/ant>
  21. &lt;/target>
  22. &lt;/project></codeblock>
  23. </info>
  24. <info>You will replace the placeholder content (indicated by the % signs) with content applicable to your
  25. environment.</info>
  26. </step>
  27. <step>
  28. <cmd>Specify project information:</cmd>
  29. <substeps>
  30. <substep importance="optional">
  31. <cmd>Set the value of the <xmlatt>name</xmlatt> attribute to the name of your
  32. project.</cmd>
  33. </substep>
  34. <substep>
  35. <cmd>Set the value of the <xmlatt>default</xmlatt> attribute to the name of a target in
  36. the build script.</cmd>
  37. <info>If the build script is invoked without specifying a target, this target will be
  38. run.</info>
  39. </substep>
  40. </substeps>
  41. </step>
  42. <step>
  43. <cmd>Set the value of the <parmname>dita.dir</parmname> property to the location of the DITA-OT.</cmd>
  44. <info>This can be a fully qualified path, or you can specify it relative to the location of the Ant build script
  45. that you are writing. </info>
  46. </step>
  47. <step>
  48. <cmd>Create the Ant target:</cmd>
  49. <substeps>
  50. <substep>
  51. <cmd>Set the value of the <xmlatt>name</xmlatt> attribute.</cmd>
  52. </substep>
  53. <substep>
  54. <cmd>Specify the value for the <parmname>args.input</parmname> property.</cmd>
  55. </substep>
  56. <substep>
  57. <cmd>Specify the value of the <parmname>transtype</parmname> property.</cmd>
  58. </substep>
  59. </substeps>
  60. </step>
  61. <step>
  62. <cmd>Save the build script.</cmd>
  63. </step>
  64. </steps>
  65. <example>
  66. <p>The following Ant build script generates CHM and PDF output for the sample DITA
  67. maps.<codeblock><coderef href="../samples/ant_sample/build-chm-pdf.xml"/></codeblock></p>
  68. <p>In addition to the mandatory parameters (<parmname>args.input</parmname> and <parmname>transtype</parmname>),
  69. the chm and pdf targets each specify some optional parameters:
  70. <ul>
  71. <li>The <parmname>args.gen.task.lbl</parmname> property is set to YES, which ensures that headings are
  72. automatically generated for the sections of task topics.</li>
  73. <li>The <parmname>output.dir</parmname> property specifies where the DITA-OT writes the output of the
  74. transformations.</li>
  75. </ul></p>
  76. <p>The pdf target also specifies that related links should be generated in the PDF, but only
  77. those links that are created by relationship tables and <xmlelement>link</xmlelement>
  78. elements.</p>
  79. <p>Finally, the all target simply specifies that both the chm and pdf target should be run.</p>
  80. </example>
  81. <postreq>Another resource for learning about Ant scripts are the files in the <filepath
  82. conref="../resources/conref-task.dita#ID/samples-dir"/><filepath>/ant_samples</filepath>
  83. directory. This directory contains the Ant build files used by the demo build, as well as
  84. templates that you can use to create Ant scripts.</postreq>
  85. </taskbody>
  86. </task>