build_xep.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <?xml version="1.0"?>
  2. <!--
  3. This file is part of the DITA Open Toolkit project.
  4. Copyright 2011 Jarno Elovirta
  5. See the accompanying LICENSE file for applicable license.
  6. -->
  7. <project name="org.dita.pdf2.xep">
  8. <target name="transform.fo2pdf.xep.test-use">
  9. <condition property="use.xep.pdf.formatter">
  10. <equals arg1="${pdf.formatter}" arg2="xep"/>
  11. </condition>
  12. </target>
  13. <target name="transform.fo2pdf.xep.init" depends="transform.fo2pdf.xep.test-use" if="use.xep.pdf.formatter">
  14. <!-- Default maximum memory to give to forked Java processes.
  15. Set this higher either in another Ant script or on the
  16. Ant command line using the -D parameter, e.g.:
  17. ant -DmaxJavaMemory=4G
  18. Memory values are integers followed by "M" for megabytes,
  19. "G" for gigabytes.
  20. On 32-bit systems, the largest memory setting will be somewhere
  21. between 1500M and 2000M depending on your system.
  22. 64-bit JVMs can use essentially unlimited memory.
  23. For memory-intensive process (very large maps),
  24. 2 or 3 gigabytes should be more than sufficient.
  25. This value is used in the @maxmemory attribute the of the Ant
  26. <java> task.
  27. -->
  28. <property name="maxJavaMemory" value="500m"/>
  29. <!-- Determine the Java architecture and set the JVM arguments
  30. appropriately.
  31. Note that the Java architecture is determined by how the
  32. JVM is started, so it is possible for the base Ant
  33. JVM to have been started in 32-bit mode on a 64-bit machine.
  34. The is64bit and is32bit properties are mutually exclusive.
  35. -->
  36. <condition property="is64bit">
  37. <!-- NOTE: The following is not a complete list but should cover
  38. most of the systems Open Toolkit users are likely
  39. to use. Add more values as they become known.
  40. -->
  41. <and>
  42. <or>
  43. <os arch="x86_64"/>
  44. <os arch="amd64"/>
  45. <os arch="ppc64"/>
  46. </or>
  47. <not>
  48. <os family="windows"/>
  49. </not>
  50. </and>
  51. </condition>
  52. <condition property="is32bit">
  53. <isfalse value="${is64bit}"/>
  54. </condition>
  55. <!-- For 64-bit machines, the value -d64 runs the
  56. the JVM in 64-bit mode. This parameter cannot
  57. be specified on 32-bit machines (that is, you cannot
  58. specify -d32 on a 32-bit machine, you get an "unrecognized
  59. option error in that case).
  60. -->
  61. <condition property="jvmArchFlag"
  62. value="-d64"
  63. else="">
  64. <istrue value="${is64bit}"/>
  65. </condition>
  66. <!-- Base JVM argument line to use with any forked Java processes.
  67. Sets the JVM architecture.
  68. Use like so:
  69. <java ...>
  70. <jvmarg line="${baseJVMArgLine}"/>
  71. ...
  72. </java>
  73. -->
  74. <property name="baseJVMArgLine" value="${jvmArchFlag} -Xmx${maxJavaMemory}"/>
  75. <condition property="use.xep.pdf.formatter">
  76. <equals arg1="${pdf.formatter}" arg2="xep"/>
  77. </condition>
  78. <condition property="temp.transformation.file" value="${dita.plugin.org.dita.pdf2.xep.dir}/xsl/fo/topic2fo_shell_xep.xsl">
  79. <and>
  80. <not><isset property="args.xsl.pdf"/></not>
  81. <isset property="use.xep.pdf.formatter"/>
  82. </and>
  83. </condition>
  84. <!-- default output format -->
  85. <condition property="xep.formatter.output-format" value="PDF">
  86. <not><isset property="xep.formatter.output-format"/></not>
  87. </condition>
  88. <!-- output file extension -->
  89. <condition property="xsl.formatter.ext" value=".ps">
  90. <and>
  91. <equals arg1="${xep.formatter.output-format}" arg2="PostScript"/>
  92. <not><isset property="xsl.formatter.ext"/></not>
  93. </and>
  94. </condition>
  95. <condition property="xsl.formatter.ext" value=".html">
  96. <and>
  97. <equals arg1="${xep.formatter.output-format}" arg2="XHTML"/>
  98. <not><isset property="xsl.formatter.ext"/></not>
  99. </and>
  100. </condition>
  101. <condition property="xsl.formatter.ext" value=".AT.xml">
  102. <and>
  103. <equals arg1="${xep.formatter.output-format}" arg2="XEP"/>
  104. <not><isset property="xsl.formatter.ext"/></not>
  105. </and>
  106. </condition>
  107. <!--condition property="xsl.formatter.ext" value=".AT.xml">
  108. <and>
  109. <equals arg1="${xep.formatter.output-format}" arg2="AT"/>
  110. <not><isset property="xsl.formatter.ext"/></not>
  111. </and>
  112. </condition-->
  113. <condition property="xsl.formatter.ext" value=".svg">
  114. <and>
  115. <equals arg1="${xep.formatter.output-format}" arg2="SVG"/>
  116. <not><isset property="xsl.formatter.ext"/></not>
  117. </and>
  118. </condition>
  119. <condition property="xsl.formatter.ext" value=".xps">
  120. <and>
  121. <equals arg1="${xep.formatter.output-format}" arg2="XPS"/>
  122. <not><isset property="xsl.formatter.ext"/></not>
  123. </and>
  124. </condition>
  125. <condition property="xsl.formatter.ext" value=".afp">
  126. <and>
  127. <equals arg1="${xep.formatter.output-format}" arg2="AFP"/>
  128. <not><isset property="xsl.formatter.ext"/></not>
  129. </and>
  130. </condition>
  131. <condition property="xsl.formatter.ext" value=".ppml">
  132. <and>
  133. <equals arg1="${xep.formatter.output-format}" arg2="PPML"/>
  134. <not><isset property="xsl.formatter.ext"/></not>
  135. </and>
  136. </condition>
  137. <condition property="xsl.formatter.ext" value=".pdf">
  138. <and>
  139. <equals arg1="${xep.formatter.output-format}" arg2="PDF"/>
  140. <not><isset property="xsl.formatter.ext"/></not>
  141. </and>
  142. </condition>
  143. </target>
  144. <!-- run XEP -->
  145. <target name="transform.fo2pdf.xep" if="use.xep.pdf.formatter">
  146. <property name="xep.dir" value="${dita.plugin.org.dita.pdf2.xep.dir}/lib/xep"/>
  147. <condition property="xep.config.file" value="${custom.xep.config}">
  148. <isset property="custom.xep.config"/>
  149. </condition>
  150. <condition property="xep.config.file" value="${xep.dir}/xep.xml">
  151. <not><isset property="custom.xep.config"/></not>
  152. </condition>
  153. <path id="xep.class.path">
  154. <fileset dir="${lib.dir}" includes="**/*.jar"/>
  155. <fileset dir="${xep.dir}/lib" includes="**/*.jar"/>
  156. <pathelement location="${fo.lib.dir}/fo.jar"/>
  157. <pathelement location="${dita.plugin.org.dita.pdf2.xep.dir}/lib/xep.jar"/>
  158. </path>
  159. <property name="xep.failOnError" value="true"/>
  160. <condition property="outputFile" value="${dita.output.dir}/${outputFile.base}${xsl.formatter.ext}">
  161. <not><isset property="outputFile"/></not>
  162. </condition>
  163. <mkdir dir="${dita.output.dir}"/>
  164. <echo level="info" taskname="xep">Processing ${pdf2.temp.dir}/topic.fo to ${outputFile}</echo>
  165. <java classname="com.idiominc.ws.opentopic.fo.xep.Runner" resultproperty="errCode"
  166. failonerror="${xep.failOnError}" fork="true" maxmemory="${maxJavaMemory}" taskname="xep">
  167. <jvmarg line="${baseJVMArgLine}"/>
  168. <arg value="${pdf2.temp.dir}/topic.fo"/>
  169. <arg value="${outputFile}"/>
  170. <arg value="failOnError=${xep.failOnError}"/>
  171. <arg value="-${xep.formatter.output-format}"/>
  172. <classpath refid="xep.class.path"/>
  173. <sysproperty key="com.renderx.xep.CONFIG" value="${xep.config.file}"/>
  174. <!--Set up catalog resolver with the DITA main catalog file, useful for solving for example SVG image DOCTYPES-->
  175. <sysproperty key="com.renderx.sax.entityresolver" value="org.apache.xml.resolver.tools.CatalogResolver"/>
  176. <sysproperty key="xml.catalog.files" value="${dita.plugin.org.dita.base.dir}/catalog-dita.xml"/>
  177. </java>
  178. <condition property="xepExitedOnError" value="true">
  179. <not><equals arg1="${errCode}" arg2="0"/></not>
  180. </condition>
  181. </target>
  182. </project>