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

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