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.

old.xml 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one
  4. or more contributor license agreements. See the NOTICE file
  5. distributed with this work for additional information
  6. regarding copyright ownership. The ASF licenses this file
  7. to you under the Apache License, Version 2.0 (the
  8. "License"); you may not use this file except in compliance
  9. with the License. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing,
  12. software distributed under the License is distributed on an
  13. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. KIND, either express or implied. See the License for the
  15. specific language governing permissions and limitations
  16. under the License.
  17. -->
  18. <!--
  19. POI Build System. Written by:
  20. Glen Stampoultzis glens at apache.org
  21. Modified by:
  22. Rainer Klute klute@rainer-klute.de
  23. Bruno Girin brunogirin@gmail.com
  24. Yegor Kozlov yegor at apache.org
  25. This build was tested with ant 1.6.2 although it will probably work with
  26. other versions. The following jar files should be available on the
  27. classpath when running ant:
  28. LIBRARY LOCATION
  29. ======= ========
  30. junit(3.8+) http://www.junit.org
  31. To build the documentation you will need to install forrest and set
  32. the FORREST_HOME environment variable. Forrest 0.5.1 required.
  33. Since POI 3.5 you will need JDK 1.5 or newer to build POI.
  34. Some people may find the tests hang when run through Ant. If this
  35. happens to you, try giving Ant some more memory when you run it, eg:
  36. ANT_OPTS="-Xmx1024m -XX:MaxPermSize=256m" ant test
  37. -->
  38. <project name="POI Build" default="help" basedir="." xmlns:mvn="antlib:org.apache.maven.artifact.ant">
  39. <description>The Apache POI project Ant build.</description>
  40. <property name="version.id" value="3.11-beta1"/>
  41. <property environment="env"/>
  42. <!-- the repository to download jars from -->
  43. <property name="repository.m2" value="http://repo1.maven.org"/>
  44. <property name="main.lib" location="lib"/>
  45. <property name="ooxml.lib" location="ooxml-lib"/>
  46. <property name="forrest.home" value="${env.FORREST_HOME}"/>
  47. <!-- Main: -->
  48. <property name="main.resource1.dir" value="src/resources/main"/>
  49. <property name="main.src" location="src/java"/>
  50. <property name="main.src.test" location="src/testcases"/>
  51. <property name="main.documentation" value="src/documentation"/>
  52. <property name="main.output.dir" location="build/classes"/>
  53. <property name="main.output.test.dir" location="build/test-classes"/>
  54. <property name="main.reports.test" location="build/test-results"/>
  55. <property name="main.testokfile" location="build/main-testokfile.txt"/>
  56. <!-- Examples: -->
  57. <property name="examples.src" location="src/examples/src"/>
  58. <property name="examples.output.dir" location="build/examples-classes"/>
  59. <!-- OOXML support: -->
  60. <property name="ooxml.src" location="src/ooxml/java"/>
  61. <property name="ooxml.resource1.dir" value="src/resources/ooxml"/>
  62. <property name="ooxml.src.test" location="src/ooxml/testcases"/>
  63. <property name="ooxml.reports.test" location="build/ooxml-test-results"/>
  64. <property name="ooxml.output.dir" location="build/ooxml-classes"/>
  65. <property name="ooxml.output.test.dir" location="build/ooxml-test-classes"/>
  66. <property name="ooxml.testokfile" location="build/ooxml-testokfile.txt"/>
  67. <property name="ooxml.lite.output.dir" location="build/ooxml-lite-classes"/>
  68. <property name="ooxml.encryption.xsd.dir" location="src/ooxml/resources/org/apache/poi/poifs/crypt"/>
  69. <!-- coverage libs -->
  70. <property name="jacoco.zip" location="${main.lib}/jacoco-0.6.5.201403032054.zip"/>
  71. <property name="jacoco.url" value="${repository.m2}/maven2/org/jacoco/jacoco/0.6.5.201403032054/jacoco-0.6.5.201403032054.zip"/>
  72. <property name="asm.jar" location="${main.lib}/asm-all-4.0.jar"/>
  73. <property name="asm.url" value="${repository.m2}/maven2/org/ow2/asm/asm-all/4.0/asm-all-4.0.jar"/>
  74. <!-- See http://www.ecma-international.org/publications/standards/Ecma-376.htm -->
  75. <!-- "Copy these file(s), free of charge" -->
  76. <property name="ooxml.xsds.ozip" location="${ooxml.lib}/OfficeOpenXML-Part4.zip"/>
  77. <property name="ooxml.xsds.izip" location="${ooxml.lib}/OfficeOpenXML-XMLSchema.zip"/>
  78. <property name="ooxml.xsds.url"
  79. value="http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%201st%20edition%20Part%204%20(PDF).zip"/>
  80. <property name="ooxml.xsds.src.dir" location="build/ooxml-xsds-src"/>
  81. <property name="ooxml.xsds.src.jar" location="${ooxml.lib}/ooxml-schemas-src-1.1.jar"/>
  82. <property name="ooxml.xsds.jar" location="${ooxml.lib}/ooxml-schemas-1.1.jar"/>
  83. <property name="ooxml.encryption.src.dir" location="build/ooxml-encryption-src"/>
  84. <property name="ooxml.encryption.src.jar" location="${ooxml.lib}/ooxml-encryption-src-1.1.jar"/>
  85. <property name="ooxml.encryption.jar" location="${ooxml.lib}/ooxml-encryption-1.1.jar"/>
  86. <property name="maven.ooxml.xsds.version.id" value="1.0"/>
  87. <property name="maven.ooxml.xsds.jar" value="ooxml-schemas-${maven.ooxml.xsds.version.id}.jar"/>
  88. <!-- Coverage -->
  89. <property name="coverage.dir" value="build/coverage"/>
  90. <!-- Exclude some uninteresting classes from coverage-instrumentation as we do not want to measure coverage in those packages anyway -->
  91. <property name="coverage.excludes" value="org.openxmlformats.*:com.*:org.junit.*:junit.*:"/>
  92. <!-- Apache RAT license check properties -->
  93. <property name="rat.reportdir" value="build/rat"/>
  94. <property name="rat.report" value="${rat.reportdir}/report.txt"/>
  95. <!-- build and distro settings -->
  96. <property name="jar.name" value="poi"/>
  97. <property name="build.site" location="build/tmp/site/build/site"/>
  98. <property name="build.site.src" location="build/tmp/site"/>
  99. <property name="apidocs.report.dir" location="${build.site}/apidocs"/>
  100. <property name="dist.dir" location="build/dist"/>
  101. <property name="halt.on.test.failure" value="true"/>
  102. <propertyset id="junit.properties">
  103. <propertyref name="POI.testdata.path"/>
  104. <propertyref name="java.awt.headless"/>
  105. <propertyref name="org.apache.poi.util.POILogger"/>
  106. </propertyset>
  107. <path id="main.classpath">
  108. <pathelement location="${main.commons-logging.jar}"/>
  109. <pathelement location="${main.commons-codec.jar}"/>
  110. <pathelement location="${main.log4j.jar}"/>
  111. <pathelement location="${main.junit.jar}"/>
  112. <pathelement location="${main.hamcrest.jar}"/>
  113. </path>
  114. <path id="ooxml.classpath">
  115. <pathelement location="${ooxml.jsr173.jar}"/>
  116. <pathelement location="${ooxml.dom4j.jar}"/>
  117. <pathelement location="${ooxml.xmlbeans.jar}"/>
  118. <pathelement location="${ooxml.xsds.jar}"/>
  119. <path refid="main.classpath"/>
  120. <pathelement location="${main.output.dir}"/>
  121. <pathelement location="${ooxml.encryption.jar}"/>
  122. </path>
  123. <path id="test.classpath">
  124. <path refid="main.classpath"/>
  125. <pathelement location="${main.output.dir}"/>
  126. <pathelement location="${main.output.test.dir}"/>
  127. </path>
  128. <path id="test.ooxml.classpath">
  129. <path refid="ooxml.classpath"/>
  130. <pathelement location="${ooxml.output.dir}"/>
  131. <pathelement location="${ooxml.output.test.dir}"/>
  132. <pathelement location="${main.output.test.dir}"/>
  133. </path>
  134. <path id="ooxml-lite.classpath">
  135. <pathelement location="${ooxml.jsr173.jar}"/>
  136. <pathelement location="${ooxml.dom4j.jar}"/>
  137. <pathelement location="${ooxml.xmlbeans.jar}"/>
  138. <pathelement location="build/ooxml-xsds-lite"/> <!-- instead of ooxml-xsds.jar use the filtered classes-->
  139. <path refid="main.classpath"/>
  140. <pathelement location="${main.output.dir}"/>
  141. <path refid="ooxml.classpath"/>
  142. <pathelement location="${ooxml.output.dir}"/>
  143. <pathelement location="${ooxml.output.test.dir}"/>
  144. <pathelement location="${main.output.test.dir}"/>
  145. </path>
  146. <path id="examples.classpath">
  147. <path refid="main.classpath"/>
  148. <pathelement location="${main.output.dir}"/>
  149. </path>
  150. <path id="lib.jacoco">
  151. <fileset dir="lib">
  152. <include name="org.jacoco*.jar" />
  153. <include name="asm-all-4*.jar" />
  154. </fileset>
  155. </path>
  156. <!-- Prints POI's Ant usage help -->
  157. <target name="help" description="Prints Apache POI's Ant usage help">
  158. <echo>
  159. This is POI ${version.id}
  160. Java Version ${ant.java.version}
  161. Timestamp ${DSTAMP}
  162. The main targets of interest are:
  163. - clean Erase all build work products (ie. everything in the build directory)
  164. - compile Compile all files from main, ooxml
  165. - test Run all unit tests from main, ooxml
  166. - jar Produce jar files
  167. - site Generate all documentation (Requires Apache Forrest)
  168. - dist Create a distribution (Requires Apache Forrest)
  169. </echo>
  170. </target>
  171. <tstamp>
  172. <format property="tstamp.year" pattern="yyyy"/>
  173. </tstamp>
  174. <target name="init" depends="fetch-jars,fetch-ooxml-jars">
  175. <mkdir dir="build"/>
  176. <mkdir dir="${main.output.dir}"/>
  177. <mkdir dir="${main.output.test.dir}"/>
  178. <mkdir dir="${main.reports.test}"/>
  179. <mkdir dir="${ooxml.output.dir}"/>
  180. <mkdir dir="${ooxml.output.test.dir}"/>
  181. <mkdir dir="${ooxml.reports.test}"/>
  182. <mkdir dir="${examples.output.dir}"/>
  183. <mkdir dir="${dist.dir}"/>
  184. <mkdir dir="${build.site}"/>
  185. </target>
  186. <target name="clean">
  187. <delete dir="build"/>
  188. </target>
  189. <target name="testexist">
  190. <echo message="Testing for ${destfile}" level="debug"/>
  191. <available file="${destfile}" property="exist"/>
  192. </target>
  193. <target name="downloadfile" unless="exist" depends="testexist">
  194. <get src="${sourcefile}" dest="${destfile}"/>
  195. </target>
  196. <target name="check-jars">
  197. <condition property="jars.present">
  198. <or>
  199. <and>
  200. <available file="${main.commons-logging.jar}"/>
  201. <available file="${main.commons-codec.jar}"/>
  202. <available file="${main.log4j.jar}"/>
  203. <available file="${main.junit.jar}"/>
  204. <available file="${main.hamcrest.jar}"/>
  205. <available file="${main.ant.jar}"/>
  206. <available file="${asm.jar}"/>
  207. <available file="${jacoco.zip}"/>
  208. <available file="${rat.jar}"/>
  209. </and>
  210. <isset property="disconnected"/>
  211. </or>
  212. </condition>
  213. </target>
  214. <target name="fetch-jars" depends="check-jars" unless="jars.present"
  215. description="Fetches needed JAR files from the Internet">
  216. <mkdir dir="${main.lib}"/>
  217. <antcall target="downloadfile">
  218. <param name="sourcefile" value="${main.commons-logging.url}"/>
  219. <param name="destfile" value="${main.commons-logging.jar}"/>
  220. </antcall>
  221. <antcall target="downloadfile">
  222. <param name="sourcefile" value="${main.commons-codec.url}"/>
  223. <param name="destfile" value="${main.commons-codec.jar}"/>
  224. </antcall>
  225. <antcall target="downloadfile">
  226. <param name="sourcefile" value="${main.log4j.url}"/>
  227. <param name="destfile" value="${main.log4j.jar}"/>
  228. </antcall>
  229. <antcall target="downloadfile">
  230. <param name="sourcefile" value="${main.junit.url}"/>
  231. <param name="destfile" value="${main.junit.jar}"/>
  232. </antcall>
  233. <antcall target="downloadfile">
  234. <param name="sourcefile" value="${main.hamcrest.url}"/>
  235. <param name="destfile" value="${main.hamcrest.jar}"/>
  236. </antcall>
  237. <antcall target="downloadfile">
  238. <param name="sourcefile" value="${main.ant.url}"/>
  239. <param name="destfile" value="${main.ant.jar}"/>
  240. </antcall>
  241. <antcall target="downloadfile">
  242. <param name="sourcefile" value="${asm.url}"/>
  243. <param name="destfile" value="${asm.jar}"/>
  244. </antcall>
  245. <antcall target="downloadfile">
  246. <param name="sourcefile" value="${jacoco.url}"/>
  247. <param name="destfile" value="${jacoco.zip}"/>
  248. </antcall>
  249. <unzip src="${jacoco.zip}" dest=".">
  250. <patternset>
  251. <include name="lib/*.jar"/>
  252. </patternset>
  253. </unzip>
  254. <antcall target="downloadfile">
  255. <param name="sourcefile" value="${rat.url}"/>
  256. <param name="destfile" value="${rat.jar}"/>
  257. </antcall>
  258. </target>
  259. <target name="check-ooxml-jars">
  260. <condition property="ooxml.jars.present">
  261. <or>
  262. <and>
  263. <available file="${ooxml.dom4j.jar}"/>
  264. <available file="${ooxml.xmlbeans.jar}"/>
  265. <available file="${ooxml.jsr173.jar}"/>
  266. <available file="${ooxml.xsds.jar}"/>
  267. </and>
  268. <isset property="disconnected"/>
  269. </or>
  270. </condition>
  271. </target>
  272. <target name="fetch-ooxml-jars" depends="check-ooxml-jars" unless="ooxml.jars.present">
  273. <mkdir dir="${ooxml.lib}"/>
  274. <antcall target="downloadfile">
  275. <param name="sourcefile" value="${ooxml.dom4j.url}"/>
  276. <param name="destfile" value="${ooxml.dom4j.jar}"/>
  277. </antcall>
  278. <antcall target="downloadfile">
  279. <param name="sourcefile" value="${ooxml.xmlbeans.url}"/>
  280. <param name="destfile" value="${ooxml.xmlbeans.jar}"/>
  281. </antcall>
  282. <antcall target="downloadfile">
  283. <param name="sourcefile" value="${ooxml.jsr173.url}"/>
  284. <param name="destfile" value="${ooxml.jsr173.jar}"/>
  285. </antcall>
  286. </target>
  287. <target name="check-ooxml-xsds">
  288. <condition property="ooxml-xsds.present">
  289. <or>
  290. <and>
  291. <available file="${ooxml.xsds.izip}"/>
  292. </and>
  293. <isset property="disconnected"/>
  294. </or>
  295. </condition>
  296. </target>
  297. <target name="fetch-ooxml-xsds" unless="ooxml-xsds.present"
  298. depends="check-ooxml-xsds"
  299. description="Fetches needed OOXML xsd files from the Internet">
  300. <get src="${ooxml.xsds.url}" dest="${ooxml.xsds.ozip}"/>
  301. <unzip src="${ooxml.xsds.ozip}" dest="${ooxml.lib}">
  302. <patternset>
  303. <include name="OfficeOpenXML-XMLSchema.zip"/>
  304. </patternset>
  305. </unzip>
  306. </target>
  307. <target name="check-compiled-ooxml-xsds" depends="fetch-ooxml-xsds">
  308. <condition property="ooxml-compiled-xsds.present">
  309. <or>
  310. <available file="${ooxml.xsds.jar}"/>
  311. <isset property="disconnected"/>
  312. </or>
  313. </condition>
  314. <condition property="ooxml-compiled-encryption-xsds.present">
  315. <or>
  316. <available file="${ooxml.encryption.jar}"/>
  317. <isset property="disconnected"/>
  318. </or>
  319. </condition>
  320. </target>
  321. <target name="compile-ooxml-xsds" unless="ooxml-compiled-xsds.present"
  322. depends="check-jars,fetch-jars,check-compiled-ooxml-xsds"
  323. description="Unpacks the OOXML xsd files, and compiles them into XmlBeans">
  324. <property name="ooxml.xsds.tmp.dir" location="build/ooxml-xsds"/>
  325. <mkdir dir="${ooxml.xsds.tmp.dir}"/>
  326. <taskdef name="xmlbean"
  327. classname="org.apache.xmlbeans.impl.tool.XMLBean"
  328. classpath="${ooxml.xmlbeans.jar}:${ooxml.jsr173.jar}"/>
  329. <!-- We need a fair amount of memory to compile the xml schema, -->
  330. <!-- but limit it in case it goes wrong! -->
  331. <!-- Pick the right amount based on 32 vs 64 bit jvm -->
  332. <condition property="ooxml.memory" value="768m" else="512m">
  333. <equals arg1="${sun.arch.data.model}" arg2="64" />
  334. </condition>
  335. <unzip src="${ooxml.xsds.izip}" dest="${ooxml.xsds.tmp.dir}"/>
  336. <!--
  337. schema="build/ooxml-xsds/"
  338. schema="build/ooxml-xsds/sml-workbook.xsd"
  339. -->
  340. <xmlbean
  341. schema="${ooxml.xsds.tmp.dir}"
  342. srcgendir="${ooxml.xsds.src.dir}"
  343. optimize="yes"
  344. destfile="${ooxml.xsds.jar}"
  345. javasource="1.5"
  346. failonerror="true"
  347. fork="true"
  348. memoryMaximumSize="${ooxml.memory}"
  349. >
  350. <classpath refid="ooxml.classpath"/>
  351. </xmlbean>
  352. <!-- Now make a jar of the schema sources -->
  353. <jar
  354. basedir="${ooxml.xsds.src.dir}"
  355. destfile="${ooxml.xsds.src.jar}"
  356. />
  357. </target>
  358. <target name="compile-ooxml-encryption-xsds" unless="ooxml-compiled-encryption-xsds.present"
  359. depends="check-jars,fetch-jars,check-compiled-ooxml-xsds"
  360. description="Compiles the OOXML encryption xsd files into XmlBeans">
  361. <taskdef name="xmlbean"
  362. classname="org.apache.xmlbeans.impl.tool.XMLBean"
  363. classpath="${ooxml.xmlbeans.jar}:${ooxml.jsr173.jar}"/>
  364. <!-- We need a fair amount of memory to compile the xml schema, -->
  365. <!-- but limit it in case it goes wrong! -->
  366. <!-- Pick the right amount based on 32 vs 64 bit jvm -->
  367. <condition property="ooxml.memory" value="768m" else="512m">
  368. <equals arg1="${sun.arch.data.model}" arg2="64" />
  369. </condition>
  370. <xmlbean
  371. schema="${ooxml.encryption.xsd.dir}"
  372. srcgendir="${ooxml.encryption.src.dir}"
  373. optimize="yes"
  374. destfile="${ooxml.encryption.jar}"
  375. javasource="1.5"
  376. failonerror="true"
  377. fork="true"
  378. memoryMaximumSize="${ooxml.memory}"
  379. >
  380. <classpath refid="ooxml.classpath"/>
  381. </xmlbean>
  382. <!-- Now make a jar of the schema sources -->
  383. <jar
  384. basedir="${ooxml.encryption.src.dir}"
  385. destfile="${ooxml.encryption.src.jar}"
  386. />
  387. </target>
  388. <target name="compile" depends="init, compile-main,
  389. compile-examples"
  390. description="Compiles the POI main classes and examples"/>
  391. <target name="compile-all" depends="compile,compile-ooxml-lite"/>
  392. <target name="compile-main" depends="init">
  393. <javac target="${jdk.version.class}"
  394. source="${jdk.version.source}"
  395. destdir="${main.output.dir}"
  396. srcdir="${main.src}"
  397. debug="${compile.debug}"
  398. encoding="${java.source.encoding}"
  399. fork="yes"
  400. includeantruntime="false">
  401. <classpath refid="main.classpath"/>
  402. </javac>
  403. <javac target="${jdk.version.class}"
  404. source="${jdk.version.source}"
  405. destdir="${main.output.test.dir}"
  406. srcdir="${main.src.test}"
  407. debug="${compile.debug}"
  408. encoding="${java.source.encoding}"
  409. fork="yes"
  410. includeantruntime="false">
  411. <classpath>
  412. <path refid="main.classpath"/>
  413. <pathelement path="${main.output.dir}"/>
  414. </classpath>
  415. </javac>
  416. <copy todir="${main.output.dir}">
  417. <fileset dir="${main.resource1.dir}"/>
  418. </copy>
  419. </target>
  420. <target name="compile-ooxml" depends="compile-main,compile-ooxml-xsds,compile-ooxml-encryption-xsds">
  421. <javac target="${jdk.version.class}"
  422. source="${jdk.version.source}"
  423. destdir="${ooxml.output.dir}"
  424. srcdir="${ooxml.src}"
  425. debug="${compile.debug}"
  426. encoding="${java.source.encoding}"
  427. fork="yes"
  428. includeantruntime="false">
  429. <classpath refid="ooxml.classpath"/>
  430. </javac>
  431. <javac target="${jdk.version.class}"
  432. source="${jdk.version.source}"
  433. destdir="${ooxml.output.test.dir}"
  434. srcdir="${ooxml.src.test}"
  435. debug="${compile.debug}"
  436. encoding="${java.source.encoding}"
  437. fork="yes"
  438. includeantruntime="false">
  439. <classpath>
  440. <path refid="ooxml.classpath"/>
  441. <pathelement path="${ooxml.output.dir}"/>
  442. <pathelement path="${main.output.test.dir}"/>
  443. </classpath>
  444. </javac>
  445. <copy todir="${ooxml.output.dir}">
  446. <fileset dir="${ooxml.resource1.dir}"/>
  447. </copy>
  448. </target>
  449. <target name="compile-version" depends="init"
  450. description="Compiles the version class">
  451. <!-- Generate the .java file -->
  452. <property name="version.java" value="${main.output.dir}/org/apache/poi/Version.java"/>
  453. <delete file="${version.java}"/>
  454. <copy
  455. file="src/resources/version/Version.java.template"
  456. tofile="${version.java}">
  457. <filterset>
  458. <filter token="VERSION" value="${version.id}"/>
  459. <filter token="DSTAMP" value="${DSTAMP}"/>
  460. </filterset>
  461. </copy>
  462. <!-- Compile -->
  463. <javac target="${jdk.version.class}" source="${jdk.version.source}"
  464. failonerror="true" destdir="${main.output.dir}" debug="on" fork="yes"
  465. srcdir="${main.output.dir}"
  466. encoding="${java.source.encoding}" includeantruntime="false">
  467. </javac>
  468. <!-- Tidy up -->
  469. <delete file="${version.java}"/>
  470. </target>
  471. <target name="jacocotask" depends="">
  472. <echo message="Coverage reporting: ${coverage.enabled}"/>
  473. <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
  474. <classpath refid="lib.jacoco"/>
  475. </taskdef>
  476. </target>
  477. <target name="test" depends="compile,jacocotask,test-main,test-ooxml"
  478. description="Tests main and ooxml"/>
  479. <target name="test-all" depends="test,test-ooxml-lite,testcoveragereport"/>
  480. <target name="testcoveragereport" depends="jacocotask" description="create test-report" xmlns:jacoco="antlib:org.jacoco.ant" if="coverage.enabled">
  481. <delete dir="${coverage.dir}"/>
  482. <mkdir dir="${coverage.dir}"/>
  483. <jacoco:report>
  484. <executiondata>
  485. <fileset dir="build">
  486. <include name="*.exec"/>
  487. </fileset>
  488. </executiondata>
  489. <structure name="Apache POI">
  490. <group name="Main">
  491. <classfiles>
  492. <fileset dir="${main.output.dir}">
  493. <exclude name="org/apache/poi/hssf/usermodel/DummyGraphics2d.class"/>
  494. </fileset>
  495. </classfiles>
  496. <sourcefiles encoding="UTF-8">
  497. <fileset dir="${main.src}"/>
  498. </sourcefiles>
  499. </group>
  500. <group name="Scratchpad">
  501. <classfiles>
  502. <fileset dir="${scratchpad.output.dir}">
  503. <exclude name="org/apache/poi/hwpf/model/types/*.class"/>
  504. <exclude name="org/apache/poi/hdf/model/hdftypes/definitions/*.class"/>
  505. </fileset>
  506. </classfiles>
  507. <sourcefiles encoding="UTF-8">
  508. <fileset dir="${scratchpad.src}"/>
  509. </sourcefiles>
  510. </group>
  511. <group name="OOXML">
  512. <classfiles>
  513. <fileset dir="${ooxml.output.dir}">
  514. <exclude name=""/>
  515. </fileset>
  516. <fileset dir="${ooxml.lite.output.dir}">
  517. <exclude name="org/openxmlformats/**"/>
  518. <exclude name="schema*/**"/>
  519. </fileset>
  520. </classfiles>
  521. <sourcefiles encoding="UTF-8">
  522. <fileset dir="${ooxml.src}"/>
  523. <!--fileset dir="${ooxml.lite.src}"/-->
  524. </sourcefiles>
  525. </group>
  526. <group name="Excelant">
  527. <classfiles>
  528. <fileset dir="${excelant.output.dir}"/>
  529. </classfiles>
  530. <sourcefiles encoding="UTF-8">
  531. <fileset dir="${excelant.src}"/>
  532. </sourcefiles>
  533. </group>
  534. </structure>
  535. <html destdir="${coverage.dir}"/>
  536. <xml destfile="${coverage.dir}/coverage.xml"/>
  537. </jacoco:report>
  538. <echo message="Coverage results are available at coverage\index.html, coverage/coverage.xml" />
  539. </target>
  540. <target name="-test-main-check">
  541. <uptodate property="main.test.notRequired" targetfile="${main.testokfile}">
  542. <srcfiles dir="${main.src}"/>
  543. <srcfiles dir="${main.src.test}"/>
  544. </uptodate>
  545. </target>
  546. <target name="test-main" unless="main.test.notRequired"
  547. depends="compile-main, -test-main-check,jacocotask" xmlns:jacoco="antlib:org.jacoco.ant">
  548. <jacoco:coverage enabled="${coverage.enabled}" excludes="${coverage.excludes}" destfile="build/jacoco-main.exec">
  549. <junit fork="yes" forkmode="once" printsummary="yes" haltonfailure="${halt.on.test.failure}"
  550. failureproperty="main.test.failed" showoutput="true">
  551. <classpath refid="test.classpath"/>
  552. <syspropertyset refid="junit.properties"/>
  553. <jvmarg value="${poi.test.locale}"/>
  554. <jvmarg value="-ea"/>
  555. <jvmarg value="-Xmx256m"/>
  556. <formatter type="plain"/>
  557. <formatter type="xml"/>
  558. <batchtest todir="${main.reports.test}">
  559. <fileset dir="${main.src.test}">
  560. <include name="**/${testpattern}.java"/>
  561. <exclude name="**/All*Tests.java"/>
  562. <exclude name="**/TestUnfixedBugs.java"/>
  563. <exclude name="**/TestcaseRecordInputStream.java"/>
  564. </fileset>
  565. </batchtest>
  566. </junit>
  567. </jacoco:coverage>
  568. <delete file="${main.testokfile}"/>
  569. <antcall target="-test-main-write-testfile"/>
  570. </target>
  571. <target name="-test-property-check" unless="testcase">
  572. <echo message="Please use -Dtestcase=org.your.testcase to run a single test"/>
  573. <fail/>
  574. </target>
  575. <target name="-test-main-write-testfile" unless="main.test.failed">
  576. <echo file="${main.testokfile}" append="false" message="testok"/>
  577. </target>
  578. <target name="-test-ooxml-check">
  579. <uptodate property="ooxml.test.notRequired" targetfile="${ooxml.testokfile}">
  580. <srcfiles dir="${ooxml.src}"/>
  581. <srcfiles dir="${ooxml.src.test}"/>
  582. </uptodate>
  583. </target>
  584. <macrodef name="ooxml-test-runner" xmlns:jacoco="antlib:org.jacoco.ant">
  585. <attribute name="classpath"/>
  586. <attribute name="type"/>
  587. <sequential>
  588. <jacoco:coverage enabled="${coverage.enabled}" excludes="${coverage.excludes}" destfile="build/jacoco-@{type}.exec">
  589. <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}"
  590. failureproperty="ooxml.test.failed">
  591. <classpath refid="@{classpath}"/>
  592. <syspropertyset refid="junit.properties"/>
  593. <jvmarg value="${poi.test.locale}"/>
  594. <jvmarg value="-ea"/>
  595. <formatter type="plain"/>
  596. <formatter type="xml"/>
  597. <batchtest todir="${ooxml.reports.test}">
  598. <fileset dir="${ooxml.src.test}">
  599. <include name="**/${testpattern}.java"/>
  600. <exclude name="**/TestUnfixedBugs.java"/>
  601. <exclude name="**/All*Tests.java"/>
  602. </fileset>
  603. </batchtest>
  604. </junit>
  605. </jacoco:coverage>
  606. </sequential>
  607. </macrodef>
  608. <target name="test-ooxml" depends="compile-main,compile-ooxml,-test-ooxml-check,jacocotask" unless="ooxml.test.notRequired">
  609. <ooxml-test-runner classpath="test.ooxml.classpath" type="ooxml"/>
  610. <delete file="${ooxml.testokfile}"/>
  611. <antcall target="-test-ooxml-write-testfile"/>
  612. </target>
  613. <target name="-test-ooxml-write-testfile" unless="ooxml.test.failed">
  614. <echo file="${ooxml.testokfile}" append="false" message="testok"/>
  615. </target>
  616. <target name="compile-ooxml-lite" depends="compile-ooxml">
  617. <property name="ooxml.lite-merged.dir" location="build/ooxml-lite-merged"/>
  618. <mkdir dir="${ooxml.lite-merged.dir}"/>
  619. <jar destfile="${ooxml.lite-merged.dir}/ooxml-lite-merged.jar">
  620. <zipfileset includes="**/*" src="${ooxml.xsds.jar}"/>
  621. <zipfileset includes="**/*" src="${ooxml.encryption.jar}"/>
  622. </jar>
  623. <java classname="org.apache.poi.util.OOXMLLite" fork="yes">
  624. <classpath>
  625. <pathelement path="${ooxml.lite-merged.dir}/ooxml-lite-merged.jar"/>
  626. </classpath>
  627. <classpath refid="test.ooxml.classpath"/>
  628. <syspropertyset refid="junit.properties"/>
  629. <jvmarg value="${poi.test.locale}"/>
  630. <arg value="-ooxml"/>
  631. <arg value="${ooxml.lite-merged.dir}/ooxml-lite-merged.jar"/>
  632. <arg value="-test"/>
  633. <arg value="${ooxml.output.test.dir}"/>
  634. <arg value="-dest"/>
  635. <arg value="${ooxml.lite.output.dir}"/>
  636. </java>
  637. </target>
  638. <target name="test-ooxml-lite" depends="jacocotask">
  639. <delete file="${ooxml.testokfile}"/>
  640. <echo message="Running ooxml tests against 'poi-ooxml-schemas'"/>
  641. <ooxml-test-runner classpath="ooxml-lite.classpath" type="ooxml-lite"/>
  642. </target>
  643. <target name="-check-docs">
  644. <uptodate property="main.docs.notRequired" targetfile="${build.site}/index.html">
  645. <srcfiles dir="${main.documentation}" />
  646. </uptodate>
  647. </target>
  648. <target name="-check-forrest-installed" unless="env.FORREST_HOME">
  649. <echo>Please install Apache Forrest (see
  650. &lt;http://forrest.apache.org/index.html&gt;) and set the
  651. FORREST_HOME environment variable!
  652. </echo>
  653. <fail message="Apache Forrest is not installed."/>
  654. </target>
  655. <target name="docs" depends="init, -check-forrest-installed, -check-docs"
  656. unless="main.docs.notRequired" description="Builds the POI website">
  657. <mkdir dir="${build.site.src}/${main.documentation}"/>
  658. <copy todir="${build.site.src}/${main.documentation}">
  659. <fileset dir="${main.documentation}"/>
  660. </copy>
  661. <copy file="forrest.properties" tofile="${build.site.src}/forrest.properties"/>
  662. <move
  663. file="${build.site.src}/src/documentation/content/xdocs/status.xml"
  664. tofile="${build.site.src}/status.xml"/>
  665. <ant antfile="${env.FORREST_HOME}/forrest.antproxy.xml" target="site">
  666. <property name="project.home" location="${build.site.src}"/>
  667. </ant>
  668. <echo>Broken links:</echo>
  669. <echo file="${build.site}/../tmp/brokenlinks.txt"/>
  670. <touch>
  671. <fileset dir="${build.site}"/>
  672. </touch>
  673. </target>
  674. <!-- Generates documentation and reports -->
  675. <target name="site" depends="docs"
  676. description="Generates POI's website's contents"/>
  677. <!-- TODO to be done with assembly -->
  678. <target name="assemble" depends="jar,jar-src">
  679. <!-- jars to include in binary assemblies -->
  680. <patternset id="bin.dist.jars">
  681. <include name="${jar.name}-${version.id}-${DSTAMP}.jar"/>
  682. <include name="${jar.name}-ooxml-${version.id}-${DSTAMP}.jar"/>
  683. <include name="${jar.name}-examples-${version.id}-${DSTAMP}.jar"/>
  684. <include name="${jar.name}-ooxml-schemas-${version.id}-${DSTAMP}.jar"/>
  685. </patternset>
  686. <!-- patterns to exclude from source assemblies -->
  687. <patternset id="src.dist.patterns"
  688. excludes="build/**,
  689. maven/**,
  690. lib/**,
  691. ooxml-lib/**,
  692. scripts/**,
  693. TEST*,
  694. *.ipr,
  695. *.iml,
  696. *.iws,
  697. *.lnk,
  698. *.rdf,
  699. *.swp,
  700. .settings/**,
  701. .classpath,
  702. .settings/**,
  703. .project"/>
  704. <property name="zipdir" value="${jar.name}-${version.id}"/>
  705. <zip destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.zip">
  706. <zipfileset dir="legal/" prefix="${zipdir}"/>
  707. <zipfileset dir="${main.lib}" prefix="${zipdir}/lib">
  708. <include name="commons-codec-*.jar"/>
  709. <include name="commons-logging-*.jar"/>
  710. <include name="junit-*.jar"/>
  711. <include name="log4j-*.jar"/>
  712. </zipfileset>
  713. <zipfileset dir="${ooxml.lib}" prefix="${zipdir}/ooxml-lib">
  714. <include name="dom4j-*.jar"/>
  715. <include name="stax-api-*.jar"/>
  716. <include name="xmlbeans-*.jar"/>
  717. </zipfileset>
  718. <zipfileset dir="${dist.dir}" prefix="${zipdir}">
  719. <patternset refid="bin.dist.jars"/>
  720. </zipfileset>
  721. <zipfileset dir="${build.site}" prefix="${zipdir}/docs"/>
  722. </zip>
  723. <zip destfile="${dist.dir}/${jar.name}-src-${version.id}-${DSTAMP}.zip">
  724. <zipfileset dir="legal/" prefix="${zipdir}" />
  725. <zipfileset dir="${build.site}" prefix="${zipdir}/docs"/>
  726. <zipfileset dir="." prefix="${zipdir}">
  727. <patternset refid="src.dist.patterns"/>
  728. </zipfileset>
  729. </zip>
  730. <tar destfile="${dist.dir}/${jar.name}-bin-${version.id}-${DSTAMP}.tar.gz"
  731. longfile="gnu"
  732. compression="gzip">
  733. <tarfileset dir="legal/" prefix="${zipdir}"/>
  734. <zipfileset dir="${main.lib}" prefix="${zipdir}/lib">
  735. <include name="commons-codec-*.jar"/>
  736. <include name="commons-logging-*.jar"/>
  737. <include name="junit-*.jar"/>
  738. <include name="log4j-*.jar"/>
  739. </zipfileset>
  740. <tarfileset dir="${ooxml.lib}" prefix="${zipdir}/ooxml-lib">
  741. <include name="dom4j-*.jar"/>
  742. <include name="stax-api-*.jar"/>
  743. <include name="xmlbeans-*.jar"/>
  744. </tarfileset>
  745. <tarfileset dir="${build.site}" prefix="${zipdir}/docs"/>
  746. <tarfileset dir="${dist.dir}" prefix="${zipdir}">
  747. <patternset refid="bin.dist.jars"/>
  748. </tarfileset>
  749. </tar>
  750. <tar destfile="${dist.dir}/${jar.name}-src-${version.id}-${DSTAMP}.tar.gz"
  751. longfile="gnu"
  752. compression="gzip">
  753. <tarfileset dir="legal/" prefix="${zipdir}" />
  754. <tarfileset dir="${build.site}" prefix="${zipdir}/docs"/>
  755. <tarfileset dir="." prefix="${zipdir}">
  756. <patternset refid="src.dist.patterns"/>
  757. </tarfileset>
  758. </tar>
  759. <!-- script to create signatures and hashes -->
  760. <copy file="maven/multisign.sh" todir="${dist.dir}"/>
  761. <echo>Creating Maven POMs</echo>
  762. <antcall target="maven-poms"/>
  763. <echo>Distribution located in ${dist.dir}</echo>
  764. <echo>Use ${dist.dir}/multisign.sh to create md5 checksums and GPG signatures</echo>
  765. </target>
  766. <target name="dist" depends="clean, compile-all, test-all, site, jar, assemble"
  767. description="Creates the entire distribution into build/dist, from scratch">
  768. </target>
  769. <target name="gump" depends="compile-all, test-all, jar"/>
  770. <target name="jenkins" depends="compile-all, test-all, jar, assemble, findbugs, rat-check"/>
  771. <available property="maven.ant.tasks.present" classname="org.apache.maven.artifact.ant.Pom"/>
  772. <target name="maven.ant.tasks-check">
  773. <fail unless="maven.ant.tasks.present">
  774. Maven ant tasks not found.
  775. Please make sure the maven-ant-tasks jar is in ANT_HOME/lib, or made
  776. available to Ant using other mechanisms like -lib or CLASSPATH.
  777. You can download the Maven Ant Tasks from http://maven.apache.org/ant-tasks/download.html
  778. </fail>
  779. </target>
  780. <macrodef name="m2-install">
  781. <attribute name="artifactId"/>
  782. <sequential>
  783. <mvn:install file="${dist.dir}/@{artifactId}-${version.id}-${DSTAMP}.jar">
  784. <pom file="${dist.dir}/@{artifactId}-${version.id}.pom"/>
  785. </mvn:install>
  786. </sequential>
  787. </macrodef>
  788. <!-- Runs Apache Rat against the source code, to spot any files -->
  789. <!-- which are missing the correct license headers -->
  790. <!-- You need to download rat from http://incubator.apache.org/rat/ -->
  791. <!-- and place the Rat jar into your ant lib before running -->
  792. <target name="rat-check" depends="check-jars,fetch-jars">
  793. <mkdir dir="${rat.reportdir}" />
  794. <typedef resource="org/apache/rat/anttasks/antlib.xml"
  795. uri="antlib:org.apache.rat.anttasks"
  796. classpath="${main.lib}/apache-rat-0.10.jar" />
  797. <rat:report xmlns:rat="antlib:org.apache.rat.anttasks" reportFile="${rat.report}">
  798. <fileset dir="src/">
  799. <exclude name="documentation/content/xdocs/dtd/" />
  800. <exclude name="documentation/content/xdocs/entity/" />
  801. <exclude name="contrib/testcases/dummy.txt" />
  802. <exclude name="examples/lib/dummy.txt" />
  803. <exclude name="resources/ooxml/org/apache/poi/xslf/usermodel/presetShapeDefinitions.xml" />
  804. <exclude name="examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt" />
  805. </fileset>
  806. </rat:report>
  807. <loadfile property="rat.reportcontent" srcFile="${rat.report}"/>
  808. <echo>${rat.reportcontent}</echo>
  809. <!-- fail the build if at least one note is in the report -->
  810. <fail><condition><matches pattern="[1-9][0-9]* Unknown Licens" string="${rat.reportcontent}"/></condition></fail>
  811. </target>
  812. </project>