You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.xml 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <?xml version="1.0"?>
  2. <!-- ===========================================================================
  3. * ================= *
  4. | How to build Fop |
  5. * ================= *
  6. Adaption from the Cocoon build.xml written by Stefano Mazzocchi
  7. by Giacomo Pati with some addition by Fotis Jannidis
  8. Introduction
  9. ============
  10. FOP is the world's first print formatter driven by XSL formatting objects. It
  11. is a Java 1.1 application that reads a formatting object tree and then turns
  12. it into a PDF document. The formatting object tree, can be in the form of an
  13. XML document (output by an XSLT engine like XT or Xalan) or can be passed in
  14. memory as a DOM Document or (in the case of XT) SAX events.
  15. FOP is part of Apache's XML project. The homepage of FOP is
  16. http:/xml.apache.org/fop
  17. HTML-Documentation can be found in the subdirectory ./docs.
  18. Installing the build tools
  19. ==========================
  20. The Fop build system is based on Jakarta Ant, which is a Java building tool
  21. originally developed for the Jakarta Tomcat project but now used in many other
  22. Apache projects and extended by many developers.
  23. Ant is a little but very handy tool that uses a build file written in XML
  24. (this file) as building instructions. For more information refer to
  25. "http://jakarta.apache.org/ant/".
  26. To make things easier for you, the Fop distribution contains a
  27. precompiled version of Ant and the build scripts take care of all the
  28. classpath issues except the following:
  29. You need to have xerces.jar, xalan.jar and bsf.jar (comes with xalan) in
  30. your classpath. You can get those from http://xml.apache.org/xerces and
  31. http://xml.apache.org/xalan respectively.
  32. Additionaly you have to make sure, that the "JAVA_HOME" environment
  33. property should be set to match the JVM you want to use. That's it.
  34. Building instructions
  35. =====================
  36. First, make sure your current working directory is where this very file is
  37. located. Then type
  38. ./build.sh (unix)
  39. .\build.bat (win32)
  40. if everything is right and all the required packages are visible, this action
  41. will generate a file called "fop.jar" in the "./build" directory. Note, that
  42. if you do further development, compilation time is reduced since Ant is able
  43. to detect which files have changed an to recompile them at need.
  44. If something went wrong, go to the FAQ section below.
  45. Also, you'll note that reusing a single JVM instance for each task, increases
  46. tremendously the performance of the whole build system, compared to other
  47. tools (i.e. make or shell scripts) where a new JVM is started for each task.
  48. Build targets
  49. =============
  50. The build system is not only responsible of compiling Fop into a jar file,
  51. but is also responsible for creating the HTML documentation, javadocs,
  52. distributions and web site. In fact, the file you have here is _exactly_ what
  53. is used by fop maintainers to take care of everything in the Fop
  54. project, no less and no more. (only partially implemented)
  55. These are the meaningful targets for this build file:
  56. - package [default] -> creates ./build/fop.jar
  57. - usage -> shows a help screen
  58. - codegen -> generates needed java sources from xml resources
  59. - docs -> generates the HTML documentation in ./build/docs
  60. - javadocs -> generates the API documentation in ./build/javadocs
  61. - dist -> generates the Fop distribution
  62. - clean -> restores the distribution to its original and clean state
  63. (excepting dist files)
  64. - distclean -> restores the distribution to its original and clean state
  65. - site -> generates the web site in ../xml-site/targets/fop (not yet impl.)
  66. ====================================== FAQ =====================================
  67. 1) Why some of the classes present in the original jar are not built anymore?
  68. The fop build system is very flexible: if a module requires a package that
  69. is not present in the classpath at build time, the module is skipped but
  70. the built process is not stopped.
  71. Here is a list of such modules and what you have to download to build them:
  72. org.apache.fop.apps.XTCommandLine ===>
  73. James Clark's XT (http://www.jclark.com/)
  74. 2) I see a lot of warnings starting like this: "Warning: file modified in the future:"
  75. Sometimes ant gives out this warnings, but the build is finished without any problems
  76. ============================================================================ -->
  77. <project default="package" basedir=".">
  78. <!-- =================================================================== -->
  79. <!-- Initialization target -->
  80. <!-- =================================================================== -->
  81. <target name="init">
  82. <tstamp/>
  83. <property name="Name" value="Fop"/>
  84. <property name="name" value="fop"/>
  85. <property name="version" value="0.19.2"/>
  86. <property name="year" value="1999-2000"/>
  87. <echo message="------------------- ${Name} ${version} [${year}] ----------------"/>
  88. <property name="build.compiler" value="classic"/>
  89. <property name="debug" value="off"/>
  90. <property name="optimize" value="on"/>
  91. <property name="deprecation" value="off"/>
  92. <property name="src.dir" value="./src"/>
  93. <property name="src.codegen" value="./src/codegen"/>
  94. <property name="docs.dir" value="./docs"/>
  95. <property name="lib.dir" value="./lib"/>
  96. <property name="packages" value="org.apache.fop.*"/>
  97. <property name="doc.generator" value="org.apache.stylebook.StyleBook"/>
  98. <property name="doc.generator.package" value="${lib.dir}/stylebook-1.0-b2.jar"/>
  99. <property name="build.dir" value="./build"/>
  100. <property name="build.src" value="./build/src"/>
  101. <property name="build.codegen" value="./build/src/codegen"/>
  102. <property name="build.dest" value="./build/classes"/>
  103. <property name="build.docs" value="./build/docs"/>
  104. <property name="build.javadocs" value="./build/javadocs"/>
  105. <property name="dist.dir" value="./dist"/>
  106. <property name="properties.dir" value="org/apache/fop/fo/properties"/>
  107. <property name="fonts.dir" value="org/apache/fop/render/pdf/fonts"/>
  108. <property name="replacestring" value="org/apache/fop"/>
  109. <property name="ignore_this" value="ignore_this.java"/>
  110. <property name="xslt" value="org.apache.xalan.xslt.Process"/>
  111. <property name="src.properties.xsl" value="${src.codegen}/properties.xsl"/>
  112. <property name="properties.xml" value="${build.codegen}/properties.xml"/>
  113. <property name="properties.xsl" value="${build.codegen}/properties.xsl"/>
  114. <property name="src.charlist.xsl" value="${src.codegen}/code-point-mapping.xsl"/>
  115. <property name="charlist.xml" value="${build.codegen}/charlist.xml"/>
  116. <property name="charlist.xsl" value="${build.codegen}/code-point-mapping.xsl"/>
  117. <property name="fontfile.xsl" value="${build.codegen}/font-file.xsl"/>
  118. <property name="Courier.xml" value="${build.codegen}/Courier.xml"/>
  119. <property name="Courier-Oblique.xml" value="${build.codegen}/Courier-Oblique.xml"/>
  120. <property name="Courier-Bold.xml" value="${build.codegen}/Courier-Bold.xml"/>
  121. <property name="Courier-BoldOblique.xml" value="${build.codegen}/Courier-BoldOblique.xml"/>
  122. <property name="Helvetica.xml" value="${build.codegen}/Helvetica.xml"/>
  123. <property name="Helvetica-Oblique.xml" value="${build.codegen}/Helvetica-Oblique.xml"/>
  124. <property name="Helvetica-Bold.xml" value="${build.codegen}/Helvetica-Bold.xml"/>
  125. <property name="Helvetica-BoldOblique.xml" value="${build.codegen}/Helvetica-BoldOblique.xml"/>
  126. <property name="Times-Roman.xml" value="${build.codegen}/Times-Roman.xml"/>
  127. <property name="Times-Italic.xml" value="${build.codegen}/Times-Italic.xml"/>
  128. <property name="Times-Bold.xml" value="${build.codegen}/Times-Bold.xml"/>
  129. <property name="Times-BoldItalic.xml" value="${build.codegen}/Times-BoldItalic.xml"/>
  130. <taskdef name="xslt" classname="Xslt"/>
  131. <available property="xt.present" classname="com.jclark.xsl.sax.XSLProcessor"/>
  132. <filter token="${replacestring}" value="${build.src}/${replacestring}"/>
  133. </target>
  134. <!-- =================================================================== -->
  135. <!-- Help on usage -->
  136. <!-- =================================================================== -->
  137. <target name="usage">
  138. <echo message=""/>
  139. <echo message=""/>
  140. <echo message="${Name} Build file"/>
  141. <echo message="-------------------------------------------------------------"/>
  142. <echo message=""/>
  143. <echo message=" available targets are:"/>
  144. <echo message=""/>
  145. <echo message=" package --> generates the ${name}.jar file (default)"/>
  146. <echo message=" codegen --> generates the java files from the xml resources"/>
  147. <echo message=" compile --> compiles the source code"/>
  148. <echo message=" docs --> generates the HTML documentation"/>
  149. <echo message=" javadocs --> generates the API documentation (java 1.2 only)"/>
  150. <echo message=" dist --> generates the ${Name} distribution as .tar.gz and .zip"/>
  151. <echo message=" clean --> cleans up the directory (except for the dist files)"/>
  152. <echo message=" distclean --> cleans up the directory"/>
  153. <echo message=" site --> generates the ${Name} web site (not yet implemented)"/>
  154. <echo message=""/>
  155. <echo message=" See the comments inside the build.xml file for more details."/>
  156. <echo message="-------------------------------------------------------------"/>
  157. <echo message=""/>
  158. <echo message=""/>
  159. </target>
  160. <!-- =================================================================== -->
  161. <!-- Prepares the build directory -->
  162. <!-- =================================================================== -->
  163. <target name="prepare" depends="init">
  164. <!-- create directories -->
  165. <echo message="Preparing the build directories"/>
  166. <mkdir dir="${build.dir}"/>
  167. <mkdir dir="${build.src}"/>
  168. <mkdir dir="${build.src}/${properties.dir}"/>
  169. <mkdir dir="${build.src}/${fonts.dir}"/>
  170. </target>
  171. <!-- =================================================================== -->
  172. <!-- Prepares the build directory -->
  173. <!-- =================================================================== -->
  174. <target name="prepare-xt" depends="prepare" if="xt.present">
  175. <copydir src="${src.dir}"
  176. dest="${build.src}"
  177. includes="**/XT*"/>
  178. </target>
  179. <!-- =================================================================== -->
  180. <!-- Prepares the source code -->
  181. <!-- =================================================================== -->
  182. <target name="prepare-src" depends="prepare, prepare-xt">
  183. <!-- copy src files -->
  184. <copydir src="${src.dir}"
  185. dest="${build.src}"
  186. excludes="**/Makefile*, **/package.html, **/XT*"/>
  187. </target>
  188. <!-- =================================================================== -->
  189. <!-- Generate the source code -->
  190. <!-- =================================================================== -->
  191. <target name="codegen" depends="prepare">
  192. <!-- resetting codegen directory -->
  193. <echo message="Resetting codegen directory"/>
  194. <!-- copy codegen directory -->
  195. <copydir src="${src.codegen}" dest="${build.codegen}" filtering="on"/>
  196. <!-- generate the java files from xml resources -->
  197. <echo message="Generating the java files from xml resources"/>
  198. <xslt infile="${properties.xml}" xsltfile="${properties.xsl}"
  199. outfile="${build.src}/${replacestring}/fo/properties/${ignore_this}" smart="yes"/>
  200. <xslt infile="${charlist.xml}" xsltfile="${charlist.xsl}"
  201. outfile="${build.src}/${replacestring}/render/pdf/CodePointMapping.java" smart="yes"/>
  202. <xslt infile="${Courier.xml}" xsltfile="${fontfile.xsl}"
  203. outfile="${build.src}/${replacestring}/render/pdf/fonts/Courier.java" smart="yes"/>
  204. <xslt infile="${Courier-Oblique.xml}" xsltfile="${fontfile.xsl}"
  205. outfile="${build.src}/${replacestring}/render/pdf/fonts/CourierOblique.java" smart="yes"/>
  206. <xslt infile="${Courier-Bold.xml}" xsltfile="${fontfile.xsl}"
  207. outfile="${build.src}/${replacestring}/render/pdf/fonts/CourierBold.java" smart="yes"/>
  208. <xslt infile="${Courier-BoldOblique.xml}" xsltfile="${fontfile.xsl}"
  209. outfile="${build.src}/${replacestring}/render/pdf/fonts/CourierBoldOblique.java" smart="yes"/>
  210. <xslt infile="${Helvetica.xml}" xsltfile="${fontfile.xsl}"
  211. outfile="${build.src}/${replacestring}/render/pdf/fonts/Helvetica.java" smart="yes"/>
  212. <xslt infile="${Helvetica-Oblique.xml}" xsltfile="${fontfile.xsl}"
  213. outfile="${build.src}/${replacestring}/render/pdf/fonts/HelveticaOblique.java" smart="yes"/>
  214. <xslt infile="${Helvetica-Bold.xml}" xsltfile="${fontfile.xsl}"
  215. outfile="${build.src}/${replacestring}/render/pdf/fonts/HelveticaBold.java" smart="yes"/>
  216. <xslt infile="${Helvetica-BoldOblique.xml}" xsltfile="${fontfile.xsl}"
  217. outfile="${build.src}/${replacestring}/render/pdf/fonts/HelveticaBoldOblique.java" smart="yes"/>
  218. <xslt infile="${Times-Roman.xml}" xsltfile="${fontfile.xsl}"
  219. outfile="${build.src}/${replacestring}/render/pdf/fonts/TimesRoman.java" smart="yes"/>
  220. <xslt infile="${Times-Italic.xml}" xsltfile="${fontfile.xsl}"
  221. outfile="${build.src}/${replacestring}/render/pdf/fonts/TimesItalic.java" smart="yes"/>
  222. <xslt infile="${Times-Bold.xml}" xsltfile="${fontfile.xsl}"
  223. outfile="${build.src}/${replacestring}/render/pdf/fonts/TimesBold.java" smart="yes"/>
  224. <xslt infile="${Times-BoldItalic.xml}" xsltfile="${fontfile.xsl}"
  225. outfile="${build.src}/${replacestring}/render/pdf/fonts/TimesBoldItalic.java" smart="yes"/>
  226. </target>
  227. <!-- =================================================================== -->
  228. <!-- Compiles the source directory -->
  229. <!-- =================================================================== -->
  230. <target name="compile" depends="codegen, prepare-src">
  231. <echo message="Compiling the sources "/>
  232. <!-- create directories -->
  233. <mkdir dir="${build.dest}"/>
  234. <javac srcdir="${build.src}"
  235. destdir="${build.dest}"
  236. debug="${debug}"
  237. deprecation="${deprecation}"
  238. optimize="${optimize}"
  239. excludes="**/${ignore_this}"/>
  240. </target>
  241. <!-- =================================================================== -->
  242. <!-- Creates the class package -->
  243. <!-- =================================================================== -->
  244. <target name="package" depends="compile">
  245. <echo message="Creating the jar file ${build.dir}/${name}.jar"/>
  246. <jar jarfile="${build.dir}/${name}.jar"
  247. basedir="${build.dest}"
  248. includes="org/**"/>
  249. </target>
  250. <!-- =================================================================== -->
  251. <!-- Prepares the docs -->
  252. <!-- =================================================================== -->
  253. <target name="prepare-docs" depends="init">
  254. <mkdir dir="${build.docs}"/>
  255. </target>
  256. <!-- =================================================================== -->
  257. <!-- Copying the documentation files -->
  258. <!-- =================================================================== -->
  259. <target name="docs" depends="prepare-docs">
  260. <echo message="Copying doc files "/>
  261. <copydir src="${docs.dir}" dest="${build.docs}" />
  262. <copydir src="${lib.dir}" dest="${build.dir}/${lib.dir}" />
  263. <copyfile src="build.xml" dest="${build.dir}/build.xml" /> -->
  264. <copyfile src="${basedir}/README" dest="${build.dir}/README" />
  265. <copyfile src="${basedir}/STATUS" dest="${build.dir}/STATUS" />
  266. <copyfile src="${basedir}/LICENSE" dest="${build.dir}/LICENSE" />
  267. <copyfile src="${basedir}/FAQ" dest="${build.dir}/FAQ" />
  268. </target>
  269. <!-- =================================================================== -->
  270. <!-- Creates the API documentation -->
  271. <!-- =================================================================== -->
  272. <target name="javadocs" depends="prepare-src">
  273. <echo message="Producing the javadoc files "/>
  274. <mkdir dir="${build.javadocs}"/>
  275. <javadoc packagenames="${packages}"
  276. sourcepath="${build.src}"
  277. destdir="${build.javadocs}"
  278. author="true"
  279. version="true"
  280. windowtitle="${Name} API"
  281. doctitle="${Name}"
  282. bottom="Copyright &#169; ${year} Apache Software Foundation. All Rights Reserved."
  283. />
  284. </target>
  285. <!-- =================================================================== -->
  286. <!-- Creates the distribution -->
  287. <!-- =================================================================== -->
  288. <target name="dist" depends="package, docs, javadocs">
  289. <echo message="Building the distribution files (zip,tar)"/>
  290. <mkdir dir="${dist.dir}"/>
  291. <copyfile src="${basedir}/build.sh" dest="${dist.dir}/build.sh" />
  292. <chmod src="${dist.dir}/build.sh" perm="ugo+rx" />
  293. <copyfile src="${basedir}/build.bat" dest="${dist.dir}/build.bat" />
  294. <copydir src="${build.dir}" dest="${dist.dir}"
  295. excludes="**/classes/**, **/${ignore_this}"/>
  296. <zip zipfile="${Name}-${version}.zip" basedir="${dist.dir}" includes="**"/>
  297. <tar tarfile="${Name}-${version}.tar" basedir="${dist.dir}" includes="**"/>
  298. <gzip zipfile="${Name}-${version}.tar.gz" src="${Name}-${version}.tar" />
  299. <delete file="${Name}-${version}.tar"/>
  300. <deltree dir="${dist.dir}"/>
  301. </target>
  302. <!-- =================================================================== -->
  303. <!-- Clean targets -->
  304. <!-- =================================================================== -->
  305. <target name="clean" depends="init">
  306. <deltree dir="${build.dir}"/>
  307. </target>
  308. <target name="distclean" depends="clean">
  309. <deltree dir="${dist.dir}"/>
  310. <delete file="${Name}-${version}.tar.gz"/>
  311. <delete file="${Name}-${version}.tar"/>
  312. <delete file="${Name}-${version}.zip"/>
  313. </target>
  314. </project>
  315. <!-- End of file -->