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 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  1. <?xml version="1.0"?>
  2. <!-- Copyright (C) 2004 The Apache Software Foundation. All rights reserved. -->
  3. <!DOCTYPE project PUBLIC "-//Ant//Project 1.5//EN" "ant.dtd">
  4. <!--
  5. POI Build System. Written by:
  6. Glen Stampoultzis glens at apache.org
  7. Modified by:
  8. Rainer Klute klute@rainer-klute.de
  9. This build was tested with ant 1.6.2 although it will probably work with
  10. other versions. The following jar files should be available on the
  11. classpath when running ant:
  12. LIBRARY LOCATION
  13. ======= ========
  14. junit(3.8+) http://www.ibiblio.org/maven/junit/jars/
  15. xerces http://www.ibiblio.org/maven/xerces/jars/
  16. jdepend http://www.ibiblio.org/maven/jdepend/jars/
  17. xalan http://www.ibiblio.org/maven/xalan/jars/
  18. The ant jar "optional.jar" should also be available otherwise the
  19. build will fail.
  20. To build the documentation you will need to install forrest and set
  21. the FORREST_HOME environment variable. Forrest 0.5.1 required.
  22. TO BE COMPLETED:
  23. Convert book.xml files to a sitemap.
  24. -->
  25. <project name="POI Build" default="help" basedir=".">
  26. <description>
  27. The POI project Ant build.
  28. </description>
  29. <property environment="env"/>
  30. <property name="repository" value="http://www.ibiblio.org/maven"/>
  31. <property name="forrest.home" value="${env.FORREST_HOME}"/>
  32. <!-- Main: -->
  33. <property name="main.resource1.dir" value="src/resources/fontmetrics"/>
  34. <property name="main.src" location="src/java"/>
  35. <property name="main.src.test" location="src/testcases"/>
  36. <property name="main.documentation" value="src/documentation"/>
  37. <property name="main.output.dir" location="build/classes"/>
  38. <property name="main.output.test.dir" location="build/test-classes"/>
  39. <property name="main.lib" location="lib"/>
  40. <property name="main.reports.test" location="build/test-results"/>
  41. <property name="main.jar1.dir" location="${main.lib}/commons-logging-1.0.1.jar"/>
  42. <property name="main.jar1.url" value="${repository}/commons-logging/jars/commons-logging-1.0.1.jar"/>
  43. <property name="main.jar2.dir" location="${main.lib}/log4j-1.2.8.jar"/>
  44. <property name="main.jar2.url" value="${repository}/log4j/jars/log4j-1.2.8.jar"/>
  45. <property name="main.testokfile" location="build/main-testokfile.txt"/>
  46. <!-- Scratchpad: -->
  47. <property name="scratchpad.src" location="src/scratchpad/src"/>
  48. <property name="scratchpad.src.test" location="src/scratchpad/testcases"/>
  49. <property name="scratchpad.lib" location="src/scratchpad/lib"/>
  50. <property name="scratchpad.reports.test" location="build/scratchpad-test-results"/>
  51. <property name="scratchpad.output.dir" location="build/scratchpad-classes"/>
  52. <property name="scratchpad.output.test.dir" location="build/scratchpad-test-classes"/>
  53. <property name="scratchpad.testokfile" location="build/scratchpad-testokfile.txt"/>
  54. <!-- Contributed software: -->
  55. <property name="contrib.src" location="src/contrib/src"/>
  56. <property name="contrib.src.test" location="src/contrib/testcases"/>
  57. <property name="contrib.lib" location="src/contrib/lib"/>
  58. <property name="contrib.reports.test" location="build/contrib-test-results"/>
  59. <property name="contrib.output.dir" location="build/contrib-classes"/>
  60. <property name="contrib.output.test.dir" location="build/contrib-test-classes"/>
  61. <property name="contrib.jar1.dir" location="${contrib.lib}/commons-beanutils-1.6.jar"/>
  62. <property name="contrib.jar1.url" value="${repository}/commons-beanutils/jars/commons-beanutils-1.6.jar"/>
  63. <property name="contrib.jar2.dir" location="${contrib.lib}/commons-collections-2.1.jar"/>
  64. <property name="contrib.jar2.url" value="${repository}/commons-collections/jars/commons-collections-2.1.jar"/>
  65. <property name="contrib.jar3.dir" location="${contrib.lib}/commons-lang-1.0-b1.jar"/>
  66. <property name="contrib.jar3.url" value="${repository}/commons-lang/jars/commons-lang-1.0-b1.jar"/>
  67. <property name="contrib.testokfile" location="build/contrib-testokfile.txt"/>
  68. <!-- Examples: -->
  69. <property name="examples.src" location="src/examples/src"/>
  70. <property name="examples.src.test" location="src/examples/testcases"/>
  71. <property name="examples.lib" location="src/examples/lib"/>
  72. <property name="examples.reports.test" location="build/examples-test-results"/>
  73. <property name="examples.output.dir" location="build/examples-classes"/>
  74. <property name="examples.output.test.dir" location="build/examples-test-classes"/>
  75. <property name="examples.jar1.dir" location="${examples.lib}/commons-beanutils-1.6.jar"/>
  76. <property name="examples.jar1.url" value="${repository}/commons-beanutils/jars/commons-beanutils-1.6.jar"/>
  77. <property name="examples.jar2.dir" location="${examples.lib}/commons-collections-2.1.jar"/>
  78. <property name="examples.jar2.url" value="${repository}/commons-collections/jars/commons-collections-2.1.jar"/>
  79. <property name="examples.jar3.dir" location="${examples.lib}/commons-lang-1.0-b1.jar"/>
  80. <property name="examples.jar3.url" value="${repository}/commons-lang/jars/commons-lang-1.0-b1.jar"/>
  81. <property name="examples.testokfile" location="build/examples-testokfile.txt"/>
  82. <property name="junit.jar1.dir" location="${main.lib}/junit-3.8.1.jar"/>
  83. <property name="junit.jar1.url" value="${repository}/junit/jars/junit-3.8.1.jar"/>
  84. <property name="build.site" location="build/tmp/site/build/site"/>
  85. <property name="build.site.src" location="build/tmp/site"/>
  86. <property name="junit.report.dir" location="${build.site}/junit"/>
  87. <property name="jdepend.report.dir" location="${build.site}/jdepend"/>
  88. <property name="jdepend.report.out.dir" location="${build.site.src}/src/documentation/content/jdepend"/>
  89. <property name="apidocs.report.dir" location="${build.site}/apidocs"/>
  90. <property name="changelog.file" location="${build.site}/changelog.html"/>
  91. <property name="dist.dir" location="build/dist"/>
  92. <property name="jar.name" value="poi"/>
  93. <property name="version.id" value="2.1"/>
  94. <property name="halt.on.test.failure" value="true"/>
  95. <path id="main.classpath">
  96. <pathelement location="${main.jar1.dir}"/>
  97. <pathelement location="${main.jar2.dir}"/>
  98. <pathelement location="${main.resource1.dir}"/>
  99. </path>
  100. <path id="scratchpad.classpath">
  101. <path refid="main.classpath"/>
  102. <pathelement location="${main.output.dir}"/>
  103. </path>
  104. <path id="contrib.classpath">
  105. <path refid="main.classpath"/>
  106. <pathelement location="${contrib.jar1.dir}"/>
  107. <pathelement location="${contrib.jar2.dir}"/>
  108. <pathelement location="${contrib.jar3.dir}"/>
  109. <pathelement location="${main.output.dir}"/>
  110. <pathelement location="${main.output.test.dir}"/>
  111. <pathelement location="${scratchpad.output.dir}"/>
  112. <pathelement location="${scratchpad.output.test.dir}"/>
  113. <pathelement location="${contrib.output.dir}"/>
  114. <pathelement location="${contrib.output.test.dir}"/>
  115. </path>
  116. <path id="examples.classpath">
  117. <path refid="main.classpath"/>
  118. <pathelement location="${main.output.dir}"/>
  119. </path>
  120. <!-- Prints POI's Ant usage help -->
  121. <target name="help" description="Prints POI's Ant usage help">
  122. <echo>
  123. - Execute "ant -projecthelp" to view a listing of the main build
  124. targets.
  125. - Execute "ant help-properties" to view a listing of some properties
  126. controlling the build process.
  127. </echo>
  128. </target>
  129. <target name="help-properties"
  130. description="Prints a listing of build controlling properties">
  131. <echo>
  132. The following properties control the build process:
  133. -Ddisconnected="true": Do not execute any targets that require an online
  134. connection to the Internet.
  135. WARNING: This list is not exhaustive.
  136. </echo>
  137. </target>
  138. <target name="with.clover" if="clover.present">
  139. <taskdef resource="clovertasks"/>
  140. <clover-setup initString="mycoverage.db"/>
  141. </target>
  142. <target name="clover.html" depends="with.clover" if="clover.present">
  143. <echo>Generating clover report</echo>
  144. <clover-report>
  145. <current outfile="build/tmp/site/build/site/clover_html">
  146. <format type="html"/>
  147. </current>
  148. </clover-report>
  149. </target>
  150. <target name="init" depends="check-jars,fetch-jars">
  151. <tstamp>
  152. <format property="tstamp.year" pattern="yyyy"/>
  153. </tstamp>
  154. <available resource="clovertasks" property="clover.present"/>
  155. <antcall target="with.clover"/>
  156. <mkdir dir="build"/>
  157. <mkdir dir="${main.output.dir}"/>
  158. <mkdir dir="${scratchpad.output.dir}"/>
  159. <mkdir dir="${contrib.output.dir}"/>
  160. <mkdir dir="${examples.output.dir}"/>
  161. <mkdir dir="${main.output.test.dir}"/>
  162. <mkdir dir="${contrib.output.test.dir}"/>
  163. <mkdir dir="${scratchpad.output.test.dir}"/>
  164. <mkdir dir="${main.reports.test}"/>
  165. <mkdir dir="${scratchpad.reports.test}"/>
  166. <mkdir dir="${contrib.reports.test}"/>
  167. <mkdir dir="${junit.report.dir}"/>
  168. <mkdir dir="${jdepend.report.dir}"/>
  169. <mkdir dir="${jdepend.report.out.dir}"/>
  170. <mkdir dir="${apidocs.report.dir}"/>
  171. <mkdir dir="${dist.dir}"/>
  172. <mkdir dir="${build.site.src}/${main.documentation}"/>
  173. <copy todir="${build.site.src}/${main.documentation}">
  174. <fileset dir="${main.documentation}"/>
  175. </copy>
  176. <copy file="forrest.properties" tofile="${build.site.src}/forrest.properties"/>
  177. </target>
  178. <target name="clean">
  179. <delete dir="build"/>
  180. </target>
  181. <target name="check-jars">
  182. <condition property="jars.present">
  183. <or>
  184. <and>
  185. <available file="${main.jar1.dir}"/>
  186. <available file="${main.jar2.dir}"/>
  187. <available file="${contrib.jar1.dir}"/>
  188. <available file="${contrib.jar2.dir}"/>
  189. <available file="${contrib.jar3.dir}"/>
  190. <available file="${junit.jar1.dir}"/>
  191. </and>
  192. <isset property="disconnected"/>
  193. </or>
  194. </condition>
  195. </target>
  196. <target name="fetch-jars" unless="jars.present"
  197. description="Fetches needed JAR files from the Internet">
  198. <get src="${main.jar1.url}" dest="${main.jar1.dir}"/>
  199. <get src="${main.jar2.url}" dest="${main.jar2.dir}"/>
  200. <get src="${contrib.jar1.url}" dest="${contrib.jar1.dir}"/>
  201. <get src="${contrib.jar2.url}" dest="${contrib.jar2.dir}"/>
  202. <get src="${contrib.jar3.url}" dest="${contrib.jar3.dir}"/>
  203. <get src="${junit.jar1.url}" dest="${junit.jar1.dir}"/>
  204. </target>
  205. <target name="compile" depends="init, compile-main, compile-scratchpad,
  206. compile-contrib, compile-examples"
  207. description="Compiles the POI main classes, scratchpad, contrib, and examples"/>
  208. <target name="compile-main" depends="init">
  209. <copy todir="${main.output.dir}">
  210. <fileset dir="${main.resource1.dir}"/>
  211. </copy>
  212. <javac srcdir="${main.src}" destdir="${main.output.dir}" debug="on" fork="yes" includeAntRuntime="no" failonerror="true">
  213. <classpath refid="main.classpath"/>
  214. </javac>
  215. <javac srcdir="${main.src.test}" destdir="${main.output.test.dir}" debug="on" fork="yes" includeAntRuntime="no" failonerror="true">
  216. <classpath>
  217. <path refid="main.classpath"/>
  218. <pathelement location="${main.output.dir}"/>
  219. <pathelement location="${junit.jar1.dir}"/>
  220. </classpath>
  221. </javac>
  222. </target>
  223. <target name="compile-scratchpad" depends="init">
  224. <javac srcdir="${scratchpad.src}" destdir="${scratchpad.output.dir}" debug="on" fork="yes" includeAntRuntime="no" failonerror="true">
  225. <classpath refid="scratchpad.classpath"/>
  226. </javac>
  227. <javac srcdir="${scratchpad.src.test}" destdir="${scratchpad.output.test.dir}" debug="on" fork="yes" includeAntRuntime="no" failonerror="true">
  228. <classpath>
  229. <path refid="scratchpad.classpath"/>
  230. <pathelement location="${scratchpad.output.dir}"/>
  231. <pathelement location="${junit.jar1.dir}"/>
  232. </classpath>
  233. </javac>
  234. </target>
  235. <target name="compile-contrib" depends="init">
  236. <javac srcdir="${contrib.src}" destdir="${contrib.output.dir}" debug="on" fork="yes" includeAntRuntime="no" failonerror="true">
  237. <classpath refid="contrib.classpath"/>
  238. </javac>
  239. <javac srcdir="${contrib.src.test}" destdir="${contrib.output.test.dir}" debug="on" fork="yes" includeAntRuntime="no" failonerror="true">
  240. <classpath>
  241. <path refid="contrib.classpath"/>
  242. <pathelement location="${contrib.output.dir}"/>
  243. <pathelement location="${junit.jar1.dir}"/>
  244. </classpath>
  245. </javac>
  246. </target>
  247. <target name="compile-examples" depends="init">
  248. <javac srcdir="${examples.src}" destdir="${examples.output.dir}" debug="on">
  249. <classpath refid="examples.classpath"/>
  250. </javac>
  251. </target>
  252. <target name="test" depends="test-main,test-scratchpad,test-contrib"
  253. description="Tests main, contrib and scratchpad"/>
  254. <target name="-test-main-check">
  255. <uptodate property="main.test.notRequired" targetfile="${main.testokfile}">
  256. <srcfiles dir="${main.src}"/>
  257. <srcfiles dir="${main.src.test}"/>
  258. </uptodate>
  259. </target>
  260. <path id="test.classpath">
  261. <path refid="main.classpath"/>
  262. <pathelement location="${main.output.dir}"/>
  263. <pathelement location="${main.output.test.dir}"/>
  264. <pathelement location="${junit.jar1.dir}"/>
  265. </path>
  266. <target
  267. name="test-main"
  268. depends="compile-main, -test-main-check, is-available-junit"
  269. unless="main.test.notRequired">
  270. <junit printsummary="no" showoutput="true" fork="no"
  271. haltonfailure="${halt.on.test.failure}" failureproperty="main.test.failed">
  272. <classpath refid="test.classpath"/>
  273. <sysproperty key="HSSF.testdata.path" file="${main.src.test}/org/apache/poi/hssf/data"/>
  274. <sysproperty key="HPSF.testdata.path" file="${main.src.test}/org/apache/poi/hpsf/data"/>
  275. <sysproperty key="java.awt.headless" value="true"/>
  276. <formatter type="plain"/>
  277. <formatter type="xml"/>
  278. <batchtest todir="${main.reports.test}">
  279. <fileset dir="${main.src.test}">
  280. <include name="**/Test*.java"/>
  281. <exclude name="**/AllTests.java"/>
  282. <exclude name="**/TestEmptyDocument.java"/>
  283. <exclude name="**/TestUnfixedBugs.java"/>
  284. </fileset>
  285. </batchtest>
  286. </junit>
  287. <delete file="${main.testokfile}"/>
  288. <antcall target="-test-main-write-testfile"/>
  289. </target>
  290. <target name="test-fail" depends = "compile-main, is-available-junit" description="run tests that are known to fail">
  291. <junit printsummary="yes" showoutput="true" filtertrace="no" haltonfailure="false" >
  292. <classpath refid="test.classpath"/>
  293. <classpath>
  294. <path refid="scratchpad.classpath"/>
  295. <pathelement location="${main.output.dir}"/>
  296. <pathelement location="${scratchpad.output.dir}"/>
  297. <pathelement location="${scratchpad.output.test.dir}"/>
  298. <pathelement location="${junit.jar1.dir}"/>
  299. </classpath>
  300. <sysproperty key="HSSF.testdata.path" file="${main.src.test}/org/apache/poi/hssf/data"/>
  301. <sysproperty key="HPSF.testdata.path" file="${main.src.test}/org/apache/poi/hpsf/data"/>
  302. <sysproperty key="HWPF.testdata.path" file="${scratchpad.src.test}/org/apache/poi/hwpf/data"/>
  303. <sysproperty key="java.awt.headless" value="true"/>
  304. <formatter type="plain" usefile="no"/>
  305. <batchtest todir="${main.reports.test}">
  306. <fileset dir="${main.src.test}">
  307. <include name="**/TestEmptyDocument.java"/>
  308. <include name="**/TestUnfixedBugs.java"/>
  309. </fileset>
  310. </batchtest>
  311. </junit>
  312. </target>
  313. <target name="single-test" depends="-test-property-check,compile-main" description="Runs a single test case specified with -Dtestcase=classname">
  314. <junit printsummary="yes" showoutput="true" filtertrace="no" haltonfailure="false" >
  315. <classpath refid="test.classpath"/>
  316. <classpath>
  317. <path refid="scratchpad.classpath"/>
  318. <pathelement location="${main.output.dir}"/>
  319. <pathelement location="${scratchpad.output.dir}"/>
  320. <pathelement location="${scratchpad.output.test.dir}"/>
  321. <pathelement location="${junit.jar1.dir}"/>
  322. </classpath>
  323. <sysproperty key="HSSF.testdata.path" file="${main.src.test}/org/apache/poi/hssf/data"/>
  324. <sysproperty key="HPSF.testdata.path" file="${main.src.test}/org/apache/poi/hpsf/data"/>
  325. <sysproperty key="HWPF.testdata.path" file="${scratchpad.src.test}/org/apache/poi/hwpf/data"/>
  326. <sysproperty key="java.awt.headless" value="true"/>
  327. <formatter type="plain" usefile="no"/>
  328. <formatter type="xml"/>
  329. <test name="${testcase}"/>
  330. </junit>
  331. </target>
  332. <target name="debug-test" depends="-test-property-check,compile-main" description="Runs a single test case specified with -Dtestcase=classname with remote debug options turned on." >
  333. <junit printsummary="no" showoutput="true" filtertrace="no" fork="yes" haltonfailure="${halt.on.test.failure}" failureproperty="main.test.failed">
  334. <jvmarg value="-Xdebug"/>
  335. <jvmarg value="-Xrunjdwp:transport=dt_socket,address=5001,server=y,suspend=y"/>
  336. <sysproperty key="java.compiler" value="NONE"/>
  337. <classpath refid="test.classpath"/>
  338. <sysproperty key="HSSF.testdata.path" file="${main.src.test}/org/apache/poi/hssf/data"/>
  339. <sysproperty key="HPSF.testdata.path" file="${main.src.test}/org/apache/poi/hpsf/data"/>
  340. <sysproperty key="java.awt.headless" value="true"/>
  341. <formatter type="plain" usefile="no"/>
  342. <test name="${testcase}"/>
  343. </junit>
  344. </target>
  345. <target name="-test-property-check" unless="testcase">
  346. <echo message="Please use -Dtestcase=org.your.testcase to run a single test"/>
  347. <fail/>
  348. </target>
  349. <target name="-test-main-write-testfile" unless="main.test.failed">
  350. <echo file="${main.testokfile}" append="false" message="testok"/>
  351. </target>
  352. <target name="-test-scratchpad-check">
  353. <uptodate property="scratchpad.test.notRequired" targetfile="${scratchpad.testokfile}">
  354. <srcfiles dir="${scratchpad.src}"/>
  355. <srcfiles dir="${scratchpad.src.test}"/>
  356. </uptodate>
  357. </target>
  358. <target name="test-scratchpad" depends="compile-scratchpad,-test-scratchpad-check" unless="scratchpad.test.notRequired">
  359. <junit printsummary="no" fork="no" haltonfailure="${halt.on.test.failure}" failureproperty="scratchpad.test.failed">
  360. <classpath>
  361. <path refid="scratchpad.classpath"/>
  362. <pathelement location="${main.output.dir}"/>
  363. <pathelement location="${scratchpad.output.dir}"/>
  364. <pathelement location="${scratchpad.output.test.dir}"/>
  365. <pathelement location="${junit.jar1.dir}"/>
  366. </classpath>
  367. <sysproperty key="HSSF.testdata.path" file="${scratchpad.src.test}/org/apache/poi/hssf/data"/>
  368. <sysproperty key="HPSF.testdata.path" file="${scratchpad.src.test}/org/apache/poi/hpsf/data"/>
  369. <sysproperty key="HDF.testdata.path" file="${scratchpad.src.test}/org/apache/poi/hdf/data"/>
  370. <sysproperty key="HWPF.testdata.path" file="${scratchpad.src.test}/org/apache/poi/hwpf/data"/>
  371. <sysproperty key="java.awt.headless" value="true"/>
  372. <formatter type="plain"/>
  373. <formatter type="xml"/>
  374. <batchtest todir="${scratchpad.reports.test}">
  375. <fileset dir="${scratchpad.src.test}">
  376. <include name="**/Test*.java"/>
  377. <exclude name="**/AllTests.java"/>
  378. </fileset>
  379. </batchtest>
  380. </junit>
  381. <delete file="${scratchpad.testokfile}"/>
  382. <antcall target="-test-scratchpad-write-testfile"/>
  383. </target>
  384. <target name="-test-scratchpad-write-testfile" unless="scratchpad.test.failed">
  385. <echo file="${scratchpad.testokfile}" append="false" message="testok"/>
  386. </target>
  387. <target name="-test-contrib-check">
  388. <uptodate property="contrib.test.notRequired" targetfile="${contrib.testokfile}">
  389. <srcfiles dir="${contrib.src}"/>
  390. <srcfiles dir="${contrib.src.test}"/>
  391. </uptodate>
  392. </target>
  393. <target name="test-contrib" depends="compile-contrib,-test-contrib-check" unless="contrib.test.notRequired">
  394. <junit printsummary="yes" fork="no" haltonfailure="${halt.on.test.failure}" failureproperty="contrib.test.failed">
  395. <classpath>
  396. <path refid="contrib.classpath"/>
  397. <pathelement location="${main.output.dir}"/>
  398. <pathelement location="${contrib.output.dir}"/>
  399. <pathelement location="${contrib.output.test.dir}"/>
  400. <pathelement location="${junit.jar1.dir}"/>
  401. </classpath>
  402. <sysproperty key="HSSF.testdata.path" file="${contrib.src.test}/org/apache/poi/hssf/data"/>
  403. <sysproperty key="HPSF.testdata.path" file="${contrib.src.test}/org/apache/poi/hpsf/data"/>
  404. <sysproperty key="java.awt.headless" value="true"/>
  405. <formatter type="plain"/>
  406. <formatter type="xml"/>
  407. <batchtest todir="${contrib.reports.test}">
  408. <fileset dir="${contrib.src.test}">
  409. <include name="**/Test*.java"/>
  410. <exclude name="**/AllTests.java"/>
  411. </fileset>
  412. </batchtest>
  413. </junit>
  414. <delete file="${contrib.testokfile}"/>
  415. <antcall target="-test-contrib-write-testfile"/>
  416. </target>
  417. <target name="-test-contrib-write-testfile" unless="contrib.test.failed">
  418. <echo file="${contrib.testokfile}" append="false" message="testok"/>
  419. </target>
  420. <target name="-check-docs">
  421. <uptodate property="main.docs.notRequired" targetfile="${build.site}/index.html">
  422. <srcfiles dir="${build.site.src}"/>
  423. </uptodate>
  424. </target>
  425. <target name="-check-forrest-installed" unless="env.FORREST_HOME">
  426. <echo>Please install Apache Forrest (see
  427. &lt;http://xml.apache.org/forrest/index.html&gt;) and set the
  428. FORREST_HOME environment variable!</echo>
  429. <fail message="Apache Forrest is not installed."/>
  430. </target>
  431. <!-- <target name="check-docs">-->
  432. <!-- <uptodate property="main.docs.notRequired" targetfile="${build.site}/index.html" >-->
  433. <!-- <srcfiles dir= "${build.site.src}"/>-->
  434. <!-- </uptodate>-->
  435. <!-- </target>-->
  436. <target name="docs" depends="init, -check-forrest-installed, -check-docs"
  437. unless="main.docs.notRequired" description="Builds the POI website">
  438. <mkdir dir="${build.site.src}/src/documentation/content/apidocs"/>
  439. <copy todir="${build.site.src}/src/documentation/content/apidocs">
  440. <fileset dir="${apidocs.report.dir}"/>
  441. </copy>
  442. <copy
  443. tofile="${build.site.src}/src/documentation/content/jdepend.ehtml"
  444. file="${jdepend.report.dir}/index.html" failonerror="false"/>
  445. <mkdir dir="${build.site.src}/src/documentation/content/junit"/>
  446. <copy todir="${build.site.src}/src/documentation/content/junit">
  447. <fileset dir="${junit.report.dir}"/>
  448. </copy>
  449. <move
  450. file="${build.site.src}/src/documentation/content/xdocs/status.xml"
  451. tofile="${build.site.src}/status.xml"/>
  452. <ant antfile="${forrest.home}/forrest.antproxy.xml" target="site">
  453. <property name="project.home" location="${build.site.src}"/>
  454. </ant>
  455. <echo>Broken links:</echo>
  456. <echo file="${build.site}/../tmp/brokenlinks.txt"/>
  457. <touch>
  458. <fileset dir="${build.site}"/>
  459. </touch>
  460. </target>
  461. <!-- Checks whether reports are required to be run. If nothing has changed then they dont. -->
  462. <target name="-check-reports">
  463. <condition property="reports.notRequired">
  464. <and>
  465. <equals arg1="${main.test.notRequired}" arg2="true"/>
  466. <equals arg1="${scratchpad.test.notRequired}" arg2="true"/>
  467. <equals arg1="${contrib.test.notRequired}" arg2="true"/>
  468. </and>
  469. </condition>
  470. </target>
  471. <!-- Generates a log of the latest changes in the CVS repository. -->
  472. <target name="cvschangelog" unless="disconnected" depends="is-available-xslt"
  473. description="Generates a CVS change log report">
  474. <antcall target="cvs-rsh-warning"/>
  475. <cvschangelog destfile="${changelog.file}" daysinpast="30"/>
  476. <style in="${changelog.file}"
  477. out="${build.site.src}/src/documentation/content/changelog.html"
  478. style="changelog.xsl">
  479. <param name="title" expression="POI Change Log"/>
  480. <param name="module" expression="jakarta-poi"/>
  481. <param name="cvsweb" expression="http://cvs.apache.org/viewcvs/"/>
  482. </style>
  483. </target>
  484. <target name="cvs-rsh-warning" unless="env.CVS_RSH">
  485. <echo>
  486. WARNING: The environment variable CVS_RSH is not set. If you cannot
  487. access the CVS repository this could be one of the reasons for the
  488. failure.
  489. </echo>
  490. </target>
  491. <!-- Creates reports and API documentation -->
  492. <target name="reports" unless="reports.notRequired" depends="-check-reports,
  493. is-available-xslt, is-available-junit, is-available-jdepend,
  494. test-ignore-failures, junitreport, jdepend, cvschangelog, javadocs,
  495. clover.html"
  496. description="Creates various reports and the API documentation">
  497. </target>
  498. <!-- Runs all JUnit tests without aborting if one of the tests fails. -->
  499. <target name="test-ignore-failures" depends="init">
  500. <antcall target="test">
  501. <param name="halt.on.test.failure" value="false"/>
  502. </antcall>
  503. </target>
  504. <!-- Produces a report of the JUnit test results -->
  505. <target name="junitreport" depends="is-available-xslt, test-ignore-failures"
  506. description="Produces a report of the JUnit test results">
  507. <junitreport todir="${junit.report.dir}">
  508. <fileset dir="${main.reports.test}">
  509. <include name="TEST-*.xml"/>
  510. </fileset>
  511. <fileset dir="${scratchpad.reports.test}">
  512. <include name="TEST-*.xml"/>
  513. </fileset>
  514. <fileset dir="${contrib.reports.test}">
  515. <include name="TEST-*.xml"/>
  516. </fileset>
  517. <report format="frames" todir="${junit.report.dir}"/>
  518. </junitreport>
  519. </target>
  520. <!-- Generates the API documentation. -->
  521. <target name="javadocs" depends="init"
  522. description="Generates the API documentation">
  523. <javadoc
  524. destdir="${apidocs.report.dir}"
  525. author="true"
  526. version="true"
  527. use="true"
  528. verbose="false"
  529. windowtitle="POI API Documentation">
  530. <packageset dir="${main.src}" defaultexcludes="yes">
  531. <include name="org/apache/poi/**"/>
  532. </packageset>
  533. <packageset dir="${scratchpad.src}" defaultexcludes="yes">
  534. <include name="org/apache/poi/**"/>
  535. </packageset>
  536. <packageset dir="${contrib.src}" defaultexcludes="yes">
  537. <include name="org/apache/poi/**"/>
  538. </packageset>
  539. <packageset dir="${examples.src}" defaultexcludes="yes">
  540. <include name="org/apache/poi/**"/>
  541. </packageset>
  542. <classpath>
  543. <path refid="main.classpath"/>
  544. <path refid="scratchpad.classpath"/>
  545. <path refid="contrib.classpath"/>
  546. <path refid="examples.classpath"/>
  547. </classpath>
  548. <doctitle><![CDATA[<h1>POI API Documentation</h1>]]></doctitle>
  549. <bottom>
  550. <![CDATA[<i>Copyright ${tstamp.year} The Apache Software Foundation or
  551. its licensors, as applicable.</i>]]>
  552. </bottom>
  553. <group title="HDF" packages="org.apache.poi.hdf*"/>
  554. <group title="HPSF" packages="org.apache.poi.hpsf*"/>
  555. <group title="HSSF" packages="org.apache.poi.hssf*"/>
  556. <group title="HWPF" packages="org.apache.poi.hwpf*"/>
  557. <group title="POIFS" packages="org.apache.poi.poifs*"/>
  558. <group title="Record Generator" packages="org.apache.poi.record*"/>
  559. <group title="Utils" packages="org.apache.poi.util*"/>
  560. <group>
  561. <title>Examples</title>
  562. <package name="org.apache.poi.hpsf.examples*"/>
  563. <package name="org.apache.poi.hssf.usermodel.examples*"/>
  564. </group>
  565. </javadoc>
  566. <antcall target="clover.html"/>
  567. </target>
  568. <!-- ================================== -->
  569. <!-- Generate records -->
  570. <!-- ================================== -->
  571. <target name="generate-records" depends="init"
  572. description="Generates HSSF records">
  573. <java classname="org.apache.poi.dev.RecordGenerator" fork="yes">
  574. <arg location="src/records/definitions"/>
  575. <arg location="src/records/styles"/>
  576. <arg location="src/java"/>
  577. <arg location="src/testcases"/>
  578. <classpath>
  579. <path refid="scratchpad.classpath">
  580. </path>
  581. <pathelement location="${main.output.dir}"/>
  582. <pathelement location="${scratchpad.output.dir}"/>
  583. </classpath>
  584. </java>
  585. </target>
  586. <!-- ================================== -->
  587. <!-- Generate types -->
  588. <!-- ================================== -->
  589. <target name="generate-types" depends="init"
  590. description="Generates word types">
  591. <java classname="org.apache.poi.dev.RecordGenerator" fork="yes">
  592. <arg location="src/types/definitions"/>
  593. <arg location="src/types/styles"/>
  594. <arg location="src/scratchpad/src"/>
  595. <arg location="src/scratchpad/testcases"/>
  596. <classpath>
  597. <path refid="scratchpad.classpath">
  598. </path>
  599. <pathelement location="${main.output.dir}"/>
  600. <pathelement location="${scratchpad.output.dir}"/>
  601. </classpath>
  602. </java>
  603. </target>
  604. <!-- Generates documentation and reports -->
  605. <target name="site" depends="reports, docs"
  606. description="Generates POI's website's contents"/>
  607. <target name="jar" depends="compile" description="Creates jar files for distribution">
  608. <jar basedir="${main.output.dir}" destfile="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar">
  609. <manifest>
  610. <attribute name="Built-By" value="${user.name}"/>
  611. <section name="common">
  612. <attribute name="Specification-Title" value="Jakarta POI"/>
  613. <attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
  614. <attribute name="Specification-Vendor" value="Apache"/>
  615. <attribute name="Implementation-Title" value="Jakarta POI"/>
  616. <attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
  617. <attribute name="Implementation-Vendor" value="Apache"/>
  618. </section>
  619. </manifest>
  620. </jar>
  621. <jar basedir="${contrib.output.dir}" destfile="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar">
  622. <manifest>
  623. <attribute name="Built-By" value="${user.name}"/>
  624. <section name="common">
  625. <attribute name="Specification-Title" value="Jakarta POI"/>
  626. <attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
  627. <attribute name="Specification-Vendor" value="Apache"/>
  628. <attribute name="Implementation-Title" value="Jakarta POI"/>
  629. <attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
  630. <attribute name="Implementation-Vendor" value="Apache"/>
  631. </section>
  632. </manifest>
  633. </jar>
  634. <jar basedir="${scratchpad.output.dir}" destfile="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar">
  635. <manifest>
  636. <attribute name="Built-By" value="${user.name}"/>
  637. <section name="common">
  638. <attribute name="Specification-Title" value="Jakarta POI"/>
  639. <attribute name="Specification-Version" value="${version.id}-${DSTAMP}"/>
  640. <attribute name="Specification-Vendor" value="Apache"/>
  641. <attribute name="Implementation-Title" value="Jakarta POI"/>
  642. <attribute name="Implementation-Version" value="${version.id}-${DSTAMP}"/>
  643. <attribute name="Implementation-Vendor" value="Apache"/>
  644. </section>
  645. </manifest>
  646. </jar>
  647. </target>
  648. <target name="dist" depends="compile,site,jar" description="Creates the entire distribution into build/dist">
  649. <zip destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.zip">
  650. <zipfileset dir="${build.site}" prefix="docs"/>
  651. <zipfileset file="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar"/>
  652. <zipfileset file="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar"/>
  653. <zipfileset file="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar"/>
  654. <zipfileset dir="legal" prefix="legal"/>
  655. </zip>
  656. <zip destfile="${dist.dir}/${jar.name}-src-${version.id}-${DSTAMP}.zip">
  657. <zipfileset dir="${build.site}" prefix="docs"/>
  658. <zipfileset dir=".">
  659. <exclude name="build/**"/>
  660. <exclude name="scripts/**"/>
  661. <exclude name="*.ipr"/>
  662. <exclude name="*.iml"/>
  663. <exclude name="*.iws"/>
  664. </zipfileset>
  665. </zip>
  666. <tar destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.tar.gz" compression="gzip">
  667. <tarfileset dir="${build.site}" prefix="docs"/>
  668. <tarfileset file="${dist.dir}/${jar.name}-${version.id}-${DSTAMP}.jar"/>
  669. <tarfileset file="${dist.dir}/${jar.name}-contrib-${version.id}-${DSTAMP}.jar"/>
  670. <tarfileset file="${dist.dir}/${jar.name}-scratchpad-${version.id}-${DSTAMP}.jar"/>
  671. <tarfileset dir="legal" prefix="legal"/>
  672. </tar>
  673. <tar destfile="${dist.dir}/${jar.name}-src-${version.id}-${DSTAMP}.tar.gz" compression="gzip">
  674. <tarfileset dir="${build.site}" prefix="docs"/>
  675. <tarfileset dir=".">
  676. <exclude name="build/**"/>
  677. <exclude name="scripts/**"/>
  678. <exclude name="*.ipr"/>
  679. <exclude name="*.iml"/>
  680. <exclude name="*.iws"/>
  681. </tarfileset>
  682. </tar>
  683. <echo>Distribution located in build/dist</echo>
  684. </target>
  685. <target name="clean-compile" depends="clean,compile"/>
  686. <target name="clean-dist" depends="clean,dist"
  687. description="Cleans the build directory then creates a distribution"/>
  688. <target name="gump" depends="test,jar"/>
  689. <!-- Generates the ANT document type definition (DTD) -->
  690. <target name="dtd"
  691. description="Generates the Ant document type definition (DTD)">
  692. <antstructure output="ant.dtd"/>
  693. </target>
  694. <!-- Still experimental targets: -->
  695. <!-- Abort the build if JUnit is missing. -->
  696. <target name="is-available-junit" depends="init">
  697. <condition property="isAvailable.junit">
  698. <available classname="junit.framework.TestCase"/>
  699. </condition>
  700. <antcall target="check-junit"/>
  701. </target>
  702. <target name="check-junit" unless="isAvailable.junit">
  703. <echo>
  704. JUnit is not available. You must download JUnit from
  705. &lt;http://www.junit.org/&gt; and include the JAR file in your
  706. classpath.
  707. </echo>
  708. <fail message="JUnit is not available."/>
  709. </target>
  710. <!-- Abort the build if JDepend is missing. -->
  711. <target name="is-available-jdepend" depends="init">
  712. <condition property="isAvailable.jdepend">
  713. <available classname="jdepend.framework.JDepend"/>
  714. </condition>
  715. <antcall target="check-jdepend"/>
  716. </target>
  717. <target name="check-jdepend" unless="isAvailable.jdepend">
  718. <echo>
  719. JDepend is not available. You must download JDepend from
  720. &lt;http://www.clarkware.com/software/JDepend.html&gt; and include the
  721. JAR file in your classpath.
  722. </echo>
  723. <fail message="JDepend is not available."/>
  724. </target>
  725. <!-- Abort the build if the Xalan XSLT processor is missing. The
  726. "junitreport" task seems to explicitly require Xalan instead of being
  727. able to cope with any XSLT processor. -->
  728. <target name="is-available-xslt" depends="init">
  729. <condition property="isAvailable.xslt">
  730. <and>
  731. <available
  732. classname="javax.xml.transform.TransformerFactory"/>
  733. <available
  734. classname="org.apache.xalan.processor.TransformerFactoryImpl"/>
  735. </and>
  736. </condition>
  737. <antcall target="check-xslt"/>
  738. </target>
  739. <target name="check-xslt" unless="isAvailable.xslt">
  740. <echo>
  741. The Xalan XSLT processor is not available. You must download Xalan from
  742. &lt;http://xml.apache.org/xalan-j/&gt; and include the JAR file in your
  743. classpath.
  744. </echo>
  745. <fail message="The Xalan XSLT processor is not available."/>
  746. </target>
  747. <!-- Runs jdepend to produce a report about package dependencies -->
  748. <target name="jdepend" depends="is-available-jdepend"
  749. description="Runs jdepend to produce a report about package dependencies">
  750. <jdepend outputfile="${jdepend.report.dir}/jdepend.xml" format="xml">
  751. <classespath>
  752. <pathelement location="${main.output.dir}"/>
  753. <pathelement location="${contrib.output.dir}"/>
  754. <pathelement location="${scratchpad.output.dir}"/>
  755. </classespath>
  756. <classpath>
  757. <path refid="main.classpath"/>
  758. <path refid="contrib.classpath"/>
  759. <path refid="scratchpad.classpath"/>
  760. </classpath>
  761. </jdepend>
  762. <style basedir="${jdepend.report.dir}"
  763. in="${jdepend.report.dir}/jdepend.xml"
  764. out="${jdepend.report.out.dir}/index.html"
  765. style="jdepend.xsl"/>
  766. </target>
  767. </project>
  768. <!-- Keep this comment at the end of the file
  769. Local variables:
  770. mode: xml
  771. sgml-omittag:nil
  772. sgml-shorttag:nil
  773. sgml-namecase-general:nil
  774. sgml-general-insert-case:lower
  775. sgml-minimize-attributes:nil
  776. sgml-always-quote-attributes:t
  777. sgml-indent-step:2
  778. sgml-indent-data:t
  779. sgml-parent-document:nil
  780. sgml-exposed-tags:nil
  781. sgml-local-catalogs:nil
  782. sgml-local-ecat-files:nil
  783. End:
  784. -->