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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <?xml version="1.0"?>
  2. <project name="IT Mill Toolkit" basedir="../" default="package">
  3. <!-- Package creation - - - - - - - - - - - - - - - - - - - - - - - - - -->
  4. <target name="package" depends="clean-all,libs,themes,demo,docs,license"
  5. description="Build public release">
  6. <zip zipfile="build/result/${package-file-name}">
  7. <fileset dir="build/result">
  8. <patternset>
  9. <include name="${product-file}-${version}/**" />
  10. </patternset>
  11. </fileset>
  12. </zip>
  13. </target>
  14. <!-- As release, but no javadoc or docbook tasks -->
  15. <target name="package-without-documentation"
  16. depends="clean-all,libs,themes,demo,package-docs,license"
  17. description="Build testing package without javadocs or manual">
  18. <zip zipfile="build/result/TESTING-${package-file-name}">
  19. <fileset dir="build/result">
  20. <patternset>
  21. <include name="${product-file}-${version}/**" />
  22. </patternset>
  23. </fileset>
  24. </zip>
  25. </target>
  26. <!-- Initialization - - - - - - - - - - - - - - - - - - - - - - - - -->
  27. <target name="init">
  28. <!-- Create result dir unless already exists -->
  29. <mkdir dir="build/result" />
  30. <property file="build/VERSION" />
  31. <property name="product-file" value="itmill-toolkit" />
  32. <property name="product-name" value="IT Mill Toolkit" />
  33. <property name="toolkit-package" value="com/itmill/toolkit" />
  34. <property file="build/html-style.properties" />
  35. <!-- Destination files -->
  36. <property name="package-file-name" value="${product-file}-${version}.zip" />
  37. <property name="lib-bin-jar-name" value="${product-file}-${version}.jar" />
  38. <property name="demo-lib-jar-name" value="${product-file}-demo-${version}.jar" />
  39. <property name="lib-src-jar-name" value="${product-file}-src-${version}.jar" />
  40. <property name="themes-jar-name" value="${product-file}-themes-${version}.jar" />
  41. <property name="demo-war-name" value="${product-file}-demo-${version}.war" />
  42. <echo message="Prepared to build ${product-file} version ${version} packages" />
  43. <!-- Output directory -->
  44. <property name="output-dir" value="build/result/${product-file}-${version}" />
  45. <mkdir dir="${output-dir}" />
  46. <!-- Create Output Directory Hierarchy -->
  47. <mkdir dir="${output-dir}/doc/manual" />
  48. <mkdir dir="${output-dir}/doc/api" />
  49. <mkdir dir="${output-dir}/lib" />
  50. <mkdir dir="${output-dir}/demo" />
  51. </target>
  52. <!-- License - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  53. <target name="license" depends="init">
  54. <copy todir="${output-dir}/lib">
  55. <fileset dir="WebContent/WEB-INF">
  56. <exclude name="**/.svn" />
  57. <include name="itmill-toolkit-license.xml" />
  58. </fileset>
  59. </copy>
  60. </target>
  61. <!-- Themes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  62. <target name="themes" depends="init">
  63. <copy todir="${output-dir}/lib/themes">
  64. <fileset dir="WebContent/WEB-INF/lib/themes">
  65. <exclude name="**/.svn" />
  66. <include name="corporate/**/*" />
  67. <include name="demo/**/*" />
  68. <include name="base/**/*" />
  69. </fileset>
  70. </copy>
  71. <!-- Brakes CSS, do not use
  72. <echo>CSS syntax check and optimizing.</echo>
  73. <for param="file">
  74. <path>
  75. <fileset dir="${output-dir}/lib/themes">
  76. <include name="**/*.css" />
  77. </fileset>
  78. </path>
  79. <sequential>
  80. <echo>@{file}</echo>
  81. <exec dir="build" executable="cmd.exe" os="Windows 2000, Windows XP" failonerror="true">
  82. <arg line="/c bin\csstidy-win.exe @{file} @{file}" />
  83. </exec>
  84. <exec dir="build" executable="bin/csstidy-osx.sh" os="Mac OS X" failonerror="true">
  85. <arg line="@{file}" />
  86. </exec>
  87. <exec dir="build" executable="bin/csstidy-linux.sh" os="Linux" failonerror="true">
  88. <arg line="@{file}" />
  89. </exec>
  90. </sequential>
  91. </for>
  92. -->
  93. <echo>JavaScript syntax check, optimizing and obfuscation.</echo>
  94. <for param="file">
  95. <path>
  96. <fileset dir="${output-dir}/lib/themes">
  97. <include name="**/*.js" />
  98. </fileset>
  99. </path>
  100. <sequential>
  101. <echo>@{file}</echo>
  102. <!-- TODO: ERROR: for some reason this does not work on Windows platform, please fix! -->
  103. <java dir="${output-dir}/lib/themes" jar="build/lib/custom_rhino.jar" fork="true" failonerror="true" maxmemory="64m" output="@{file}">
  104. <arg value="-c" />
  105. <arg value="@{file}" />
  106. </java>
  107. </sequential>
  108. </for>
  109. <fixcrlf srcdir="${output-dir}/lib/themes" includes="**/*.js **/*.css" eol="lf" eof="remove" />
  110. <jar jarfile="${output-dir}/lib/${themes-jar-name}" compress="false">
  111. <fileset dir="${output-dir}/lib/themes">
  112. <patternset>
  113. <include name="corporate/**/*" />
  114. <include name="base/**/*" />
  115. </patternset>
  116. </fileset>
  117. </jar>
  118. </target>
  119. <!-- Libs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  120. <!-- Copy and preprocess sources for packaging -->
  121. <target name="preprocess-src" depends="init">
  122. <mkdir dir="build/result/src" />
  123. <copy todir="build/result/src">
  124. <filterset>
  125. <filter token="VERSION" value="${version}" />
  126. </filterset>
  127. <fileset dir="src">
  128. <patternset>
  129. <include name="**/*.java" />
  130. <include name="**/*.html" />
  131. </patternset>
  132. </fileset>
  133. </copy>
  134. <!-- Convert to CRLF's and tabs -->
  135. <fixcrlf srcdir="build/result/src" eol="crlf" tablength="4" tab="remove" includes="**/*.java" />
  136. <!-- Un-Filtered files -->
  137. <copy todir="build/result/src">
  138. <fileset dir="src">
  139. <patternset>
  140. <include name="**/*.gif" />
  141. <include name="**/*.jpg" />
  142. <include name="**/*.png" />
  143. </patternset>
  144. </fileset>
  145. </copy>
  146. </target>
  147. <target name="compile-java" depends="preprocess-src">
  148. <!-- Compile -->
  149. <mkdir dir="build/result/classes" />
  150. <javac srcdir="build/result/src" destdir="build/result/classes" classpath="build/lib/servlet-api.jar" includes="${toolkit-package}/**" />
  151. </target>
  152. <target name="libs" depends="compile-java">
  153. <!-- Create binary JAR -->
  154. <jar jarfile="${output-dir}/lib/${lib-bin-jar-name}" compress="true" includes="${toolkit-package}/**" basedir="build/result/classes" excludes="${toolkit-package}/demo/**" />
  155. <!-- Create source JAR -->
  156. <jar jarfile="${output-dir}/lib/${lib-src-jar-name}" compress="true">
  157. <fileset dir="build/result/src">
  158. <patternset>
  159. <include name="${toolkit-package}/**/*.java" />
  160. <exclude name="${toolkit-package}/demo/**/*.java" />
  161. </patternset>
  162. </fileset>
  163. </jar>
  164. </target>
  165. <!-- Demo - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  166. <target name="demo" depends="libs,compile-java,themes">
  167. <echo>Building demo</echo>
  168. <java2html srcdir="build/result/src/${toolkit-package}/demo" destdir="build/result/src/${toolkit-package}/demo" includes="**/*.java" style="eclipse" showLineNumbers="true" showFileName="true" showTableBorder="false" />
  169. <!-- have to use "temp" dir for some reason here. Overwrite does not work, at least on Linux -->
  170. <copy todir="build/result/srcTemp" overwrite="true">
  171. <filterchain>
  172. <expandproperties />
  173. <replacetokens begintoken="&lt;" endtoken=">">
  174. <token key="body" value="${html.body.tag}${html.body.start1}${product-name}${html.body.start2}" />
  175. <token key="/body" value="${html.body.end}${html.body.endtag}" />
  176. <token key="head" value="${html.head.tag}${html.head.style}" />
  177. </replacetokens>
  178. </filterchain>
  179. <fileset dir="build/result/src">
  180. <exclude name="**/.svn" />
  181. <include name="**/*.html" />
  182. </fileset>
  183. </copy>
  184. <!-- Create demo binary JAR, including pictures -->
  185. <mkdir dir="build/result/lib"/>
  186. <jar jarfile="build/result/lib/${demo-lib-jar-name}" includes="${toolkit-package}/demo/**" basedir="build/result/classes" compress="true">
  187. <fileset dir="build/result/src">
  188. <patternset>
  189. <include name="${toolkit-package}/demo/**/*.jpg" />
  190. <include name="${toolkit-package}/demo/**/*.png" />
  191. <include name="${toolkit-package}/demo/**/*.gif" />
  192. </patternset>
  193. </fileset>
  194. </jar>
  195. <war warfile="${output-dir}/demo/${product-file}.war" webxml="WebContent/WEB-INF/web.xml">
  196. <!-- WebContent: htmls, styles, license-->
  197. <fileset dir="WebContent">
  198. <exclude name="**/.svn" />
  199. <exclude name="WEB-INF/web.xml" />
  200. <exclude name="WEB-INF/lib/themes/**/*" />
  201. <exclude name="WEB-INF/classes" />
  202. <exclude name="WEB-INF/classes/**/*" />
  203. <include name="**/*" />
  204. </fileset>
  205. <!-- Toolkit package and themes -->
  206. <lib dir="${output-dir}/lib">
  207. <include name="${lib-bin-jar-name}" />
  208. <include name="${themes-jar-name}" />
  209. </lib>
  210. <!-- Demo package and themes -->
  211. <lib dir="build/result/lib">
  212. <include name="${demo-lib-jar-name}" />
  213. </lib>
  214. <lib dir="${output-dir}/lib">
  215. <include name="themes/demo/**/*" />
  216. </lib>
  217. <!-- Calc and HelloWorld source and html source -->
  218. <fileset dir="build/result">
  219. <include name="src/${toolkit-package}/demo/Calc.*" />
  220. <include name="src/${toolkit-package}/demo/HelloWorld.*" />
  221. </fileset>
  222. </war>
  223. <!-- Jetty -->
  224. <copy todir="${output-dir}/demo">
  225. <fileset dir="build/demo">
  226. <exclude name="**/.svn" />
  227. </fileset>
  228. </copy>
  229. <!-- Sources -->
  230. <copy todir="${output-dir}/demo/src">
  231. <fileset dir="build/result/src">
  232. <include name="src/${toolkit-package}/demo/Calc.*" />
  233. <include name="src/${toolkit-package}/demo/HelloWorld.*" />
  234. </fileset>
  235. </copy>
  236. </target>
  237. <!-- Documentation- - - - - - - - - - - - - - - - - - - - - - - - - -->
  238. <target name="docs" depends="javadoc,manual-pdf,manual-html,package-docs">
  239. </target>
  240. <target name="package-docs" depends="init">
  241. <copy todir="${output-dir}">
  242. <filterchain>
  243. <expandproperties />
  244. <replacetokens begintoken="&lt;" endtoken=">">
  245. <token key="body" value="${html.body.tag}${html.body.start1}${product-name}${html.body.start2}" />
  246. <token key="/body" value="${html.body.end}${html.body.endtag}" />
  247. </replacetokens>
  248. </filterchain>
  249. <fileset dir="">
  250. <exclude name="**/.svn" />
  251. <include name="*.html" />
  252. <include name="*.txt" />
  253. </fileset>
  254. </copy>
  255. <copy todir="${output-dir}">
  256. <fileset dir="">
  257. <filename name="*.pdf" />
  258. </fileset>
  259. </copy>
  260. <copy todir="${output-dir}/doc/manual/html-style">
  261. <fileset dir="doc/manual/html-style">
  262. <exclude name="**/.svn" />
  263. <exclude name="**/test.html" />
  264. </fileset>
  265. </copy>
  266. <copy todir="${output-dir}/doc">
  267. <fileset dir="doc">
  268. <exclude name="**/.svn" />
  269. <include name="dtd/**/*.dtd" />
  270. </fileset>
  271. </copy>
  272. </target>
  273. <target name="javadoc" depends="preprocess-src">
  274. <javadoc destdir="${output-dir}/doc/api" author="true" version="true" use="true" windowtitle="${product-name}" classpath="build/lib/servlet-api.jar">
  275. <packageset dir="build/result/src">
  276. <include name="${toolkit-package}/**" />
  277. <exclude name="${toolkit-package}/demo/**" />
  278. </packageset>
  279. <doctitle>${javadoc.doctitle}</doctitle>
  280. <!-- <header><![CDATA[<script type="text/javascript" src=".html-style/style.js"></script>]]></header> -->
  281. <bottom>${javadoc.bottom}</bottom>
  282. <link offline="true" href="http://java.sun.com/j2se/1.5.0/docs/api/" packagelistLoc="build/javadoc/j2se-1.5.0" />
  283. <link offline="true" href="http://java.sun.com/j2ee/1.4/docs/api/" packagelistLoc="build/javadoc/j2ee-1.4" />
  284. </javadoc>
  285. </target>
  286. <target name="book-part2" depends="dbdoclet">
  287. <!-- TODO Add XSLT to transform dbdoclet results to book part 2 -->
  288. </target>
  289. <target name="dbdoclet" depends="preprocess-src">
  290. <javadoc access="public" charset="UTF-8" docencoding="UTF-8" encoding="ISO-8859-15" failonerror="yes" classpath="build/lib/servlet-api.jar" maxmemory="512m" source="1.5">
  291. <packageset dir="build/result/src">
  292. <include name="${toolkit-package}/**" />
  293. <exclude name="${toolkit-package}/demo/**" />
  294. </packageset>
  295. <doclet name="org.dbdoclet.doclet.docbook.DocBookDoclet" path="build/lib/jdk${java.specification.version}/dbdoclet.jar">
  296. <param name="-d" value="result/docbook" />
  297. </doclet>
  298. </javadoc>
  299. </target>
  300. <target name="manual-pdf" depends="init">
  301. <!-- TODO Include XEP-based FO building in future -->
  302. </target>
  303. <target name="manual-html" depends="init">
  304. <delete file="build/docbook/conf/temp.xsl" />
  305. <copy file="build/docbook/conf/custom-html-docbook.xsl" tofile="build/docbook/conf/temp.xsl">
  306. <filterchain>
  307. <replacetokens>
  308. <token key="BODYHEADER" value="${html.body.start1}${docbook.head.title}${html.body.start2}" />
  309. <token key="BODYFOOTER" value="${html.body.end}" />
  310. </replacetokens>
  311. </filterchain>
  312. </copy>
  313. <path id="docbook-xsl.classpath">
  314. <pathelement path="build/lib/fserializer.jar" />
  315. <pathelement path="build/lib/xalan.jar" />
  316. <pathelement path="build/lib/xercesImpl.jar" />
  317. <pathelement path="build/lib/xml-apis.jar" />
  318. </path>
  319. <java classname="org.apache.xalan.xslt.Process" failonerror="yes" fork="yes" maxmemory="1300m">
  320. <arg value="-in" />
  321. <arg value="doc/manual/book.xml" />
  322. <arg value="-xsl" />
  323. <arg value="build/docbook/conf/temp.xsl" />
  324. <arg value="-out" />
  325. <arg value="${output-dir}/doc/manual/index.html" />
  326. <arg value="-param" />
  327. <arg value="use.extensions" />
  328. <arg value="1" />
  329. <classpath refid="docbook-xsl.classpath" />
  330. </java>
  331. <delete file="build/docbook/conf/temp.xsl" />
  332. <copy todir="${output-dir}/doc/manual/img">
  333. <fileset dir="doc/manual/img">
  334. <exclude name="**/.svn" />
  335. </fileset>
  336. </copy>
  337. </target>
  338. <!-- Clean results - - - - - - - - - - - - - - - - - - - - - - - - - -->
  339. <target name="clean-all" depends="">
  340. <delete includeemptydirs="true" defaultexcludes="false">
  341. <fileset dir="build/result" includes="**/*" />
  342. </delete>
  343. <delete file="build/docbook/conf/temp.xsl" />
  344. </target>
  345. <!-- ant contrib required for flow control (for loop) -->
  346. <taskdef resource="net/sf/antcontrib/antlib.xml">
  347. <classpath>
  348. <pathelement location="build/lib/ant-contrib-1.0b3.jar" />
  349. </classpath>
  350. </taskdef>
  351. <!-- java2html converter -->
  352. <taskdef name="java2html" classname="de.java2html.anttasks.Java2HtmlTask" classpath="build/lib/java2html.jar" />
  353. </project>