build_init.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <?xml version="1.0"?>
  2. <!-- This file is part of the DITA Open Toolkit project hosted on
  3. Sourceforge.net. See the accompanying license.txt file for
  4. applicable licenses.-->
  5. <!-- (c) Copyright IBM Corp. 2006 All Rights Reserved. -->
  6. <project name="ditaot-init">
  7. <!-- Default maximum memory to give to forked Java processes.
  8. Set this higher either in another Ant script or on the
  9. Ant command line using the -D parameter, e.g.:
  10. ant -DmaxJavaMemory=4G
  11. Memory values are integers followed by "M" for megabytes,
  12. "G" for gigabytes.
  13. On 32-bit systems, the largest memory setting will be somewhere
  14. between 1500M and 2000M depending on your system.
  15. 64-bit JVMs can use essentially unlimited memory.
  16. For memory-intensive process (very large maps),
  17. 2 or 3 gigabytes should be more than sufficient.
  18. This value is used in the @maxmemory attribute the of the Ant
  19. <java> task.
  20. -->
  21. <property name="maxJavaMemory" value="500m"/>
  22. <!-- Read configuration properties -->
  23. <property file="${dita.dir}/lib/org.dita.dost.platform/plugin.properties"/>
  24. <property file="${dita.dir}/lib/configuration.properties"/>
  25. <xmlcatalog id="dita.catalog">
  26. <catalogpath path="${dita.plugin.org.dita.base.dir}/catalog-dita.xml"/>
  27. </xmlcatalog>
  28. <!-- Determine the Java architecture and set the JVM arguments
  29. appropriately.
  30. Note that the Java architecture is determined by how the
  31. JVM is started, so it is possible for the base Ant
  32. JVM to have been started in 32-bit mode on a 64-bit machine.
  33. The is64bit and is32bit properties are mutually exclusive.
  34. -->
  35. <condition property="is64bit">
  36. <!-- NOTE: The following is not a complete list but should cover
  37. most of the systems Open Toolkit users are likely
  38. to use. Add more values as they become known.
  39. -->
  40. <and>
  41. <or>
  42. <os arch="x86_64"/>
  43. <os arch="amd64"/>
  44. <os arch="ppc64"/>
  45. </or>
  46. <not>
  47. <os family="windows"/>
  48. </not>
  49. </and>
  50. </condition>
  51. <condition property="is32bit">
  52. <isfalse value="${is64bit}"/>
  53. </condition>
  54. <!-- For 64-bit machines, the value -d64 runs the
  55. the JVM in 64-bit mode. This parameter cannot
  56. be specified on 32-bit machines (that is, you cannot
  57. specify -d32 on a 32-bit machine, you get an "unrecognized
  58. option error in that case).
  59. -->
  60. <condition property="jvmArchFlag"
  61. value="-d64"
  62. else="">
  63. <istrue value="${is64bit}"/>
  64. </condition>
  65. <!-- Base JVM argument line to use with any forked Java processes.
  66. Sets the JVM architecture.
  67. Use like so:
  68. <java ...>
  69. <jvmarg line="${baseJVMArgLine}"/>
  70. ...
  71. </java>
  72. -->
  73. <property name="baseJVMArgLine" value="${jvmArchFlag} -Xmx${maxJavaMemory}"/>
  74. <!-- Deprecated -->
  75. <path id="dost.jar.path" refid="dost.class.path"/>
  76. <taskdef name="pipeline"
  77. classname="org.dita.dost.invoker.ExtensibleAntInvoker">
  78. <classpath refid="dost.class.path" />
  79. </taskdef>
  80. <taskdef name="dita-ot-echo"
  81. classname="org.dita.dost.log.DITAOTEchoTask">
  82. <classpath refid="dost.class.path" />
  83. </taskdef>
  84. <taskdef name="dita-ot-fail"
  85. classname="org.dita.dost.log.DITAOTFailTask">
  86. <classpath refid="dost.class.path" />
  87. </taskdef>
  88. <taskdef name="dita-ot-copy"
  89. classname="org.dita.dost.util.DITAOTCopy">
  90. <classpath refid="dost.class.path" />
  91. </taskdef>
  92. <taskdef name="job-property" classname="org.dita.dost.platform.JobPropertyTask">
  93. <classpath refid="dost.class.path"/>
  94. </taskdef>
  95. <typedef name="isabsolute"
  96. classname="org.dita.dost.util.IsAbsolute">
  97. <classpath refid="dost.class.path" />
  98. </typedef>
  99. <typedef name="dita-fileset" classname="org.dita.dost.util.JobSourceSet">
  100. <classpath refid="dost.class.path" />
  101. </typedef>
  102. <macrodef name="job-helper" >
  103. <attribute name="file"/>
  104. <attribute name="property"/>
  105. <sequential>
  106. <xslt in="${dita.temp.dir}/.job.xml" out="${dita.temp.dir}/@{file}"
  107. style="${dita.plugin.org.dita.base.dir}/xsl/job-helper.xsl"
  108. force="true" taskname="job-helper">
  109. <param name="property" expression="@{property}"/>
  110. <outputproperty name="encoding" value="${file.encoding}"/>
  111. </xslt>
  112. </sequential>
  113. </macrodef>
  114. <tstamp>
  115. <format property="current.date" pattern="yyyyMMddHHmmssSSS"/>
  116. </tstamp>
  117. <property name="base.temp.dir" location="${basedir}/temp"/>
  118. <property name="dita.temp.dir" location="${base.temp.dir}${file.separator}temp${current.date}" />
  119. <property name="output.dir" location="${basedir}/out" />
  120. <property environment="env" />
  121. <!-- property values end -->
  122. <target name="build-init"
  123. depends="check-arg,
  124. log-arg" />
  125. <!-- property value validation begin -->
  126. <target name="check-arg"
  127. description="Validate and init input arguments">
  128. <!-- begin to check input parameters -->
  129. <dita-ot-fail id="DOTA003F">
  130. <condition>
  131. <and>
  132. <isset property="args.xsl" />
  133. <not>
  134. <available file="${args.xsl}" type="file" />
  135. </not>
  136. </and>
  137. </condition>
  138. <param name="1" location="${args.xsl}"/>
  139. </dita-ot-fail>
  140. <!-- end to check input parameters -->
  141. <!-- begin to init required parameters -->
  142. <dita-ot-fail id="DOTA012W">
  143. <condition>
  144. <isset property="dita.input.valfile" />
  145. </condition>
  146. <param name="1" value="dita.input.valfile"/>
  147. <param name="2" value="args.filter"/>
  148. </dita-ot-fail>
  149. <condition property="dita.input.valfile" value="${args.filter}">
  150. <and>
  151. <isset property="args.filter"/>
  152. <not><isset property="dita.input.valfile"/></not>
  153. </and>
  154. </condition>
  155. <dita-ot-fail id="DOTA013F">
  156. <condition>
  157. <and>
  158. <isset property="args.filter" />
  159. <not>
  160. <available file="${args.filter}" type="file" />
  161. </not>
  162. </and>
  163. </condition>
  164. <param name="1" location="${args.filter}"/>
  165. </dita-ot-fail>
  166. <condition property="filter-stage" value="early">
  167. <not>
  168. <isset property="filter-stage"/>
  169. </not>
  170. </condition>
  171. <condition property="filter-on-parse" value="true">
  172. <and>
  173. <equals arg1="${filter-stage}" arg2="early"/>
  174. </and>
  175. </condition>
  176. <!-- append a '.' to out.ext if args.outext not contains '.' -->
  177. <condition property="out.ext" value=".${args.outext}">
  178. <and>
  179. <isset property="args.outext" />
  180. <not>
  181. <contains string="${args.outext}" substring="." />
  182. </not>
  183. </and>
  184. </condition>
  185. <condition property="out.ext" value="${args.outext}">
  186. <and>
  187. <isset property="args.outext" />
  188. <contains string="${args.outext}" substring="." />
  189. </and>
  190. </condition>
  191. <condition property="args.grammar.cache"
  192. value="yes">
  193. <not>
  194. <isset property="args.grammar.cache" />
  195. </not>
  196. </condition>
  197. <condition property="args.xml.systemid.set"
  198. value="yes">
  199. <not>
  200. <isset property="args.xml.systemid.set" />
  201. </not>
  202. </condition>
  203. <!-- end to init required parameters -->
  204. <!-- create required directories -->
  205. <mkdir dir="${output.dir}" />
  206. <delete dir="${dita.temp.dir}" quiet="false"/>
  207. <mkdir dir="${dita.temp.dir}" />
  208. <condition property="args.logdir" value="${output.dir}">
  209. <not>
  210. <isset property="args.logdir" />
  211. </not>
  212. </condition>
  213. <!-- Validate the xml file or not,default is validation(true)-->
  214. <condition property="validate" value="true">
  215. <not>
  216. <isset property="validate" />
  217. </not>
  218. </condition>
  219. <!-- Related links to output: none, all, nofamily -->
  220. <condition property="include.rellinks" value="">
  221. <equals arg1="${args.rellinks}" arg2="none"/>
  222. </condition>
  223. <condition property="include.rellinks" value="#default sibling friend cousin ancestor descendant sample external other">
  224. <equals arg1="${args.rellinks}" arg2="nofamily"/>
  225. </condition>
  226. <condition property="include.rellinks" value="#default child sibling friend next previous cousin ancestor descendant sample external other">
  227. <or>
  228. <equals arg1="${args.hide.parent.link}" arg2="yes"/>
  229. <equals arg1="${args.rellinks}" arg2="noparent"/>
  230. </or>
  231. </condition>
  232. <condition property="include.rellinks" value="#default parent child sibling friend next previous cousin ancestor descendant sample external other">
  233. <or>
  234. <equals arg1="${args.rellinks}" arg2="all"/>
  235. <not><isset property="args.rellinks"/></not>
  236. </or>
  237. </condition>
  238. <!--solution for the output control-->
  239. <condition property="generate.copy.outer" value="1">
  240. <not>
  241. <isset property="generate.copy.outer" />
  242. </not>
  243. </condition>
  244. <condition property="onlytopic.in.map" value="false">
  245. <not>
  246. <isset property="onlytopic.in.map" />
  247. </not>
  248. </condition>
  249. <!--
  250. default value : warn
  251. fail :1a) Fail quickly if files are going to be generated/copied outside of that directory
  252. warn :1b) Complete if files will be generated/copied outside, but log a warning
  253. quiet :1c) Quietly finish with only those files (no warning or error)
  254. -->
  255. <condition property="outer.control" value="warn">
  256. <not>
  257. <isset property="outer.control" />
  258. </not>
  259. </condition>
  260. <condition property="inner.transform">
  261. <equals arg1="${generate.copy.outer}" arg2="1"/>
  262. </condition>
  263. <condition property="old.transform">
  264. <equals arg1="${generate.copy.outer}" arg2="3"></equals>
  265. </condition>
  266. <condition property="conserve-memory" value="false">
  267. <not><isset property="conserve-memory"/></not>
  268. </condition>
  269. </target>
  270. <target name="log-arg">
  271. <condition property="xml.parser" value="XMLReader ${org.xml.sax.driver}">
  272. <and>
  273. <isset property="org.xml.sax.driver"/>
  274. <not><isset property="xml.parser"/></not>
  275. </and>
  276. </condition>
  277. <condition property="xml.parser" value="Xerces">
  278. <and>
  279. <available classname="org.apache.xerces.parsers.SAXParser"/>
  280. <not><isset property="xml.parser"/></not>
  281. </and>
  282. </condition>
  283. <condition property="xml.parser" value="Xerces in Sun JDK 1.5">
  284. <and>
  285. <available classname="com.sun.org.apache.xerces.internal.parsers.SAXParser"/>
  286. <not><isset property="xml.parser"/></not>
  287. </and>
  288. </condition>
  289. <condition property="xml.parser" value="Crimson">
  290. <and>
  291. <available classname="org.apache.crimson.parser.XMLReaderImpl"/>
  292. <not><isset property="xml.parser"/></not>
  293. </and>
  294. </condition>
  295. <condition property="xslt.parser" value="Saxon" else="Xalan">
  296. <or>
  297. <available classname="net.sf.saxon.StyleSheet"/>
  298. <available classname="net.sf.saxon.Transform"/>
  299. </or>
  300. </condition>
  301. <condition property="collator" value="ICU" else="JDL">
  302. <available classname="com.ibm.icu.text.Collator"/>
  303. </condition>
  304. <!-- output parameters info -->
  305. <echo level="info">*****************************************************************</echo>
  306. <echo level="info">* basedir = ${basedir}</echo>
  307. <echo level="info">* dita.dir = ${dita.dir}</echo>
  308. <!--echo level="info">* input = ${args.input}</echo-->
  309. <echo level="info">* transtype = ${transtype}</echo>
  310. <echo level="info">* tempdir = ${dita.temp.dir}</echo>
  311. <echo level="info">* outputdir = ${output.dir}</echo>
  312. <echo level="info">* clean.temp = ${clean.temp}</echo>
  313. <echo level="info">* DITA-OT version = ${otversion}</echo>
  314. <echo level="info">* XML parser = ${xml.parser}</echo>
  315. <echo level="info">* XSLT processor = ${xslt.parser}</echo>
  316. <echo level="info">* collator = ${collator}</echo>
  317. <echo level="info">*****************************************************************</echo>
  318. <echoproperties regex="^(arg|preprocess|dita)" taskname="echo" failonerror="false"/>
  319. <echo level="info">*****************************************************************</echo>
  320. </target>
  321. </project>