migrating-ant-to-dita.dita 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA General Task//EN" "generalTask.dtd">
  3. <!--This file is part of the DITA Open Toolkit project. See the accompanying LICENSE.md file for applicable licenses.-->
  4. <task id="migrating-ant-to-dita">
  5. <title>Migrating Ant builds to use the <cmdname>dita</cmdname> command</title>
  6. <shortdesc>Although Ant builds are still supported in the DITA Open Toolkit, you might want to switch to use the new
  7. <cmdname>dita</cmdname> command.</shortdesc>
  8. <taskbody>
  9. <context>
  10. <p>Building output with the <cmdname>dita</cmdname> command is often easier than using Ant. In particular, you can
  11. use <filepath>.properties</filepath> files to specify sets of DITA-OT parameters for each build.</p>
  12. <p>You can include the <cmdname>dita</cmdname> command in shell scripts to perform multiple builds.</p>
  13. <note conref="../resources/conref-task.dita#ID/dita-in-path"/>
  14. </context>
  15. <steps>
  16. <step>
  17. <cmd>In your Ant build file, identify the properties set in each build target.</cmd>
  18. <info>
  19. <note>Some build parameters might be specified as properties of the project as a whole. You can refer to a
  20. build log to see a list of all properties that were set for the build.</note>
  21. </info>
  22. </step>
  23. <step>
  24. <cmd>Create a <filepath>.properties</filepath> file for each build and specify the needed build parameters, one
  25. per line, in the format <codeph>name = value</codeph>.</cmd>
  26. </step>
  27. <step>
  28. <cmd>Use the <cmdname>dita</cmdname> command to perform each build, referencing your
  29. <filepath>.properties</filepath> file with the <parmname>-propertyfile</parmname> option.</cmd>
  30. </step>
  31. </steps>
  32. <example><title>Example: Ant build</title>
  33. <p>Sample build file: <filepath id="samples-dir"
  34. ><varname>dita-ot-dir</varname>/docsrc/samples</filepath><filepath>/ant_sample/build-chm-pdf.xml</filepath>
  35. <codeblock><coderef href="../samples/ant_sample/build-chm-pdf.xml"/></codeblock></p></example>
  36. <example>
  37. <title>Example: <filepath>.properties</filepath> files with <cmdname>dita</cmdname> command</title>
  38. <p>The following <filepath>.properties</filepath> files and <cmdname>dita</cmdname> commands are equivalent to the
  39. example Ant build.</p>
  40. <p>Sample <filepath>.properties</filepath> file: <filepath conref="../resources/conref-task.dita#ID/samples-dir"
  41. /><filepath>/properties/chm.properties</filepath><codeblock><coderef href="../samples/properties/chm.properties"/></codeblock></p>
  42. <p>Sample <filepath>.properties</filepath> file: <filepath conref="../resources/conref-task.dita#ID/samples-dir"
  43. /><filepath>/properties/pdf.properties</filepath><codeblock><coderef href="../samples/properties/pdf.properties"/></codeblock></p>
  44. <p>Run from <filepath conref="../resources/conref-task.dita#ID/samples-dir"/>:</p>
  45. <codeblock><filepath conref="../resources/conref-task.dita#ID/dita-cmd"/> -input sequence.ditamap -format htmlhelp -propertyfile properties/chm.properties
  46. <filepath conref="../resources/conref-task.dita#ID/dita-cmd"/> -input taskbook.ditamap -format pdf -propertyfile properties/pdf.properties</codeblock>
  47. </example>
  48. <example>
  49. <title>Example: Call the <cmdname>dita</cmdname> command from an Ant build</title>
  50. <p>In some cases, you might still want to use an Ant build to implement some pre- or post-processing steps, but
  51. also want the convenience of using the <cmdname>dita</cmdname> command with <filepath>.properties</filepath>
  52. files to define the parameters for each build. This can be accomplished with Ant's <xmlelement>exec</xmlelement>
  53. task.</p>
  54. <p>This example uses a <xmlelement>dita-cmd</xmlelement> Ant macro defined in the <filepath
  55. conref="../resources/conref-task.dita#ID/samples-dir"/><filepath>/ant_sample/dita-cmd.xml</filepath> file.</p>
  56. <p>Sample build file: <filepath conref="../resources/conref-task.dita#ID/samples-dir"
  57. /><filepath>/ant_sample/build-chm-pdf-hybrid.xml</filepath>
  58. <codeblock><coderef href="../samples/ant_sample/build-chm-pdf-hybrid.xml"/></codeblock>
  59. </p>
  60. </example>
  61. </taskbody>
  62. </task>