build.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. Guarana Release
  4. Call task called 'deploy' to build a full release.
  5. -->
  6. <project name="Guarana" default="all" basedir=".">
  7. <property file="ant.properties"/>
  8. <property file="components"/>
  9. <property name="components" value="all"/>
  10. <property file="debug"/>
  11. <property name="debug" value="off"/>
  12. <property file="resolution"/>
  13. <property name="resolution" value="360x640"/>
  14. <property file="theme"/>
  15. <property name="theme" value="default"/>
  16. <property file="demofolder"/>
  17. <property name="demofolder" value="S60"/>
  18. <property file="plist.component"/>
  19. <property name="plist.component" value="rating"/>
  20. <echo message="Using theme: ${theme}"/>
  21. <property name="release.filename" value="Guarana"/>
  22. <property name="concatenated-themeroller" value="Themeroller"/>
  23. <property name="concatenated" value="Guarana"/>
  24. <property name="concatenated-lib" value="jquery"/>
  25. <property name="build.dir" value="tools"/>
  26. <property name="dist.dir" value="Guarana"/>
  27. <property name="base.dir" value="../"/>
  28. <property name="src.dir" value="${base.dir}/src/"/>
  29. <property name="lib.dir" value="${base.dir}/lib/"/>
  30. <property name="nokia.theme.dir" value="/themes/nokia/"/>
  31. <property name="themeroller.theme.dir" value="/themes/themeroller/${theme}-theme"/>
  32. <property name="lib.files" value="jquery.js, jquery-ui.js, jquery.scrollTo.js"/>
  33. <property name="core.files" value="defaults.js, core.js"/>
  34. <property description="YUI Compressor" name="yui-jar" value="${build.dir}/yuicompressor-2.4.2.jar"/>
  35. <property description="Closure Compiler" name="closure-compiler-jar" value="${build.dir}/compiler.jar"/>
  36. <property file="minifier"/>
  37. <property name="minifier" value="yui"/>
  38. <taskdef resource="net/sf/antcontrib/antcontrib.properties">
  39. <classpath>
  40. <pathelement location="${build.dir}/ant-contrib-0.6.jar"/>
  41. </classpath>
  42. </taskdef>
  43. <target name="all" depends="whitespace, clean, concatenate, copy-all, minify, replace-paths, wgz" description="Release builder"></target>
  44. <target name="deploy" depends="whitespace, clean, concatenate, minify, copy"></target>
  45. <target description="Zip the package" name="wgz">
  46. <echo message="Zipping files."/>
  47. <exec executable="zip">
  48. <arg line="-r"/>
  49. <arg line="${dist.dir}/../${release.filename}.wgz"/>
  50. <arg line="${dist.dir}"/>
  51. </exec>
  52. </target>
  53. <target name="concatenate">
  54. <echo message="Building concatenated"/>
  55. <mkdir dir="${dist.dir}/lib/"/>
  56. <mkdir dir="${dist.dir}/lib/jquery/"/>
  57. <delete file="${dist.dir}/lib/${concatenated}.js"/>
  58. <concat destfile="${dist.dir}/lib/${concatenated}.js">
  59. <filelist dir="${src.dir}/" files="${core.files}"/>
  60. </concat>
  61. <delete file="${dist.dir}/lib/${concatenated-lib}.js"/>
  62. <concat destfile="${dist.dir}/lib/jquery/${concatenated-lib}.js">
  63. <filelist dir="${lib.dir}/jquery/" files="${lib.files}"/>
  64. </concat>
  65. <echo message="Concatenated built."/>
  66. <concat destfile="${dist.dir}/${themeroller.theme.dir}/${concatenated-themeroller}.css">
  67. <fileset dir="${base.dir}/${themeroller.theme.dir}/" includes="ui.core.css"/>
  68. <fileset dir="${base.dir}/${themeroller.theme.dir}/" includes="ui.*.css" excludes="ui.all.css, ui.core.css, ui.base.cs, ui.theme.css"/>
  69. <fileset dir="${base.dir}/${themeroller.theme.dir}/" includes="ui.theme.css"/>
  70. </concat>
  71. <echo message="Concatenated theme."/>
  72. <mkdir dir="${dist.dir}/lib/i18n/"/>
  73. <delete file="${dist.dir}/lib/i18n/${concatenated}.i18n.js"/>
  74. <concat destfile="${dist.dir}/lib/i18n/${concatenated}.i18n.js" encoding="utf-8">
  75. <fileset dir="${src.dir}/i18n/" includes="*.js"/>
  76. </concat>
  77. <echo message="Concatenated i18n built."/>
  78. </target>
  79. <target name="minify" depends="concatenate" description="Remove all comments and whitespace, no compression, great in combination with GZip">
  80. <echo message="Building minified"/>
  81. <delete file="${dist.dir}/lib/${concatenated}.min.js"/>
  82. <delete file="${dist.dir}/lib/jquery/${concatenated-lib}.min.js"/>
  83. <delete file="${dist.dir}/lib/i18n/${concatenated}.i18n.min.js"/>
  84. <if>
  85. <equals arg1="${debug}" arg2="off" />
  86. <then>
  87. <if>
  88. <equals arg1="${minifier}" arg2="yui" />
  89. <then>
  90. <echo message="Minifier: YUI Compressor" />
  91. <apply executable="java" parallel="false">
  92. <fileset dir="${dist.dir}/lib/" includes="*.js"/>
  93. <arg line="-jar"/>
  94. <arg path="${yui-jar}"/>
  95. <arg value="--charset"/>
  96. <arg value="UTF-8"/>
  97. <srcfile/>
  98. <arg line="-o"/>
  99. <mapper type="glob" from="*.js" to="${dist.dir}/lib/*.min.js"/>
  100. <targetfile/>
  101. </apply>
  102. </then>
  103. </if>
  104. <if>
  105. <equals arg1="${minifier}" arg2="google" />
  106. <then>
  107. <echo message="Minifier: Google Compiler" />
  108. <apply executable="java" parallel="false">
  109. <fileset dir="${dist.dir}/lib/" includes="*.js"/>
  110. <arg line="-jar"/>
  111. <arg path="${closure-compiler-jar}"/>
  112. <arg line="--compilation_level" />
  113. <arg value="SIMPLE_OPTIMIZATIONS"/>
  114. <arg line="--js"/>
  115. <srcfile/>
  116. <arg line="--js_output_file"/>
  117. <mapper type="glob" from="*.js" to="${dist.dir}/lib/*.min.js"/>
  118. <targetfile/>
  119. </apply>
  120. </then>
  121. </if>
  122. <delete>
  123. <fileset dir="${dist.dir}/lib/" includes="*.js" excludes="*.min.js" />
  124. </delete>
  125. <move overwrite="true" todir="${dist.dir}/lib/" includeemptydirs="false">
  126. <fileset dir="${dist.dir}/lib/"></fileset>
  127. <mapper type="glob" from="*.min.js" to="*.js"/>
  128. </move>
  129. </then>
  130. </if>
  131. <apply executable="java" parallel="false">
  132. <filelist dir="${dist.dir}/lib/jquery/" files="${concatenated-lib}.js"/>
  133. <arg line="-jar"/>
  134. <arg path="${yui-jar}"/>
  135. <arg value="--charset"/>
  136. <arg value="UTF-8"/>
  137. <srcfile/>
  138. <arg line="-o"/>
  139. <mapper type="glob" from="*.js" to="${dist.dir}/lib/jquery/*.min.js"/>
  140. <targetfile/>
  141. </apply>
  142. <delete>
  143. <fileset dir="${dist.dir}/lib/jquery/" includes="*.js" excludes="*.min.js" />
  144. </delete>
  145. <move overwrite="true" todir="${dist.dir}/lib/jquery/" includeemptydirs="false">
  146. <fileset dir="${dist.dir}/lib/jquery/"></fileset>
  147. <mapper type="glob" from="*.min.js" to="*.js"/>
  148. </move>
  149. <echo message="Minified built."/>
  150. <apply executable="java" parallel="false">
  151. <filelist dir="${dist.dir}/lib/i18n/" files="${concatenated}.i18n.js"/>
  152. <arg line="-jar"/>
  153. <arg path="${yui-jar}"/>
  154. <arg value="--charset"/>
  155. <arg value="UTF-8"/>
  156. <srcfile/>
  157. <arg line="-o"/>
  158. <mapper type="glob" from="*.js" to="${dist.dir}/lib/i18n/*.min.js"/>
  159. <targetfile/>
  160. </apply>
  161. <delete>
  162. <fileset dir="${dist.dir}/lib/i18n/" includes="*.js" excludes="*.min.js" />
  163. </delete>
  164. <move overwrite="true" todir="${dist.dir}/lib/i18n/" includeemptydirs="false">
  165. <fileset dir="${dist.dir}/lib/i18n/"></fileset>
  166. <mapper type="glob" from="*.min.js" to="*.js"/>
  167. </move>
  168. <echo message="Minified i18n built."/>
  169. </target>
  170. <target description="Copy needed folders" name="copy-all">
  171. <echo message="Copying files"/>
  172. <mkdir dir="${dist.dir}"/>
  173. <copy overwrite="true" todir="${dist.dir}/${nokia.theme.dir}/ext-theme/${theme}/${resolution}/">
  174. <fileset dir="${base.dir}/${nokia.theme.dir}/ext-theme/${theme}/${resolution}/"/>
  175. </copy>
  176. <copy overwrite="true" todir="${dist.dir}/demos/">
  177. <fileset dir="${base.dir}/demos/${demofolder}/" includes="**/"/>
  178. </copy>
  179. <copy overwrite="true" todir="${dist.dir}/${themeroller.theme.dir}/images/">
  180. <fileset dir="${base.dir}/${themeroller.theme.dir}/images/"/>
  181. </copy>
  182. <copy overwrite="true" todir="${dist.dir}/${nokia.theme.dir}/base/images/">
  183. <fileset dir="${base.dir}/${nokia.theme.dir}/base/images/"/>
  184. </copy>
  185. <copy overwrite="true" todir="${dist.dir}/test/">
  186. <fileset dir="${base.dir}/test/"/>
  187. </copy>
  188. <copy overwrite="true" todir="${dist.dir}/">
  189. <filelist dir="${base.dir}/" files="Info.plist, config.xml, icon.png"/>
  190. </copy>
  191. <java jar="${build.dir}/js.jar" fork="true">
  192. <arg value="${build.dir}/js/copydependencies.js" />
  193. <arg value="${components}" />
  194. </java>
  195. <replaceregexp match="window\.NOKIA_PATH_BASE = '\.\.\/';" replace="window.NOKIA_PATH_BASE = '../../';" flags="g" byline="true">
  196. <fileset dir="${dist.dir}/lib/" includes="Guarana.js"/>
  197. </replaceregexp>
  198. <replaceregexp match="window\.NOKIA_PATH_JAVASCRIPT = NOKIA_PATH_BASE \+ 'src\/';" replace="window.NOKIA_PATH_JAVASCRIPT = NOKIA_PATH_BASE + 'lib/';" flags="g" byline="true">
  199. <fileset dir="${dist.dir}/lib/" includes="Guarana.js"/>
  200. </replaceregexp>
  201. <echo message="Files copied."/>
  202. </target>
  203. <target description="Copy needed folders" name="copy">
  204. <echo message="Copying files"/>
  205. <mkdir dir="${dist.dir}"/>
  206. <copy overwrite="true" todir="${dist.dir}/${themeroller.theme.dir}/images/">
  207. <fileset dir="${base.dir}/${themeroller.theme.dir}/images/"/>
  208. </copy>
  209. <copy overwrite="true" todir="${dist.dir}/${nokia.theme.dir}/base/images/">
  210. <fileset dir="${base.dir}/${nokia.theme.dir}/base/images/"/>
  211. </copy>
  212. </target>
  213. <target name="clean">
  214. <delete dir="${dist.dir}"/>
  215. <delete file="${dist.dir}/../${release.filename}.wgz"/>
  216. </target>
  217. <target name="whitespace">
  218. <replaceregexp match="[\t ]+$" replace="" flags="g" byline="true">
  219. <fileset dir="${src.dir}" includes="*.js"/>
  220. <fileset dir="${src.dir}/i18n/" includes="*.js"/>
  221. </replaceregexp>
  222. <echo message="All trailing spaces removed."/>
  223. </target>
  224. <target name="replace-paths">
  225. <replaceregexp match="^\s*\u003C(link rel=\u0022stylesheet\u0022 href=|script src=)[^\u003E]+\u003E(\u003C[/][^\u003E]+\u003E)?" replace="" flags="g" byline="true">
  226. <fileset dir="${dist.dir}/demos/" includes="**/*.html*/"/>
  227. <fileset dir="${dist.dir}/test/" includes="*.html"/>
  228. </replaceregexp>
  229. <replaceregexp match="^\s*\u0024\('#switcher'\)\.themeswitcher\(\)\;" replace="" flags="g" byline="true">
  230. <fileset dir="${dist.dir}/demos/" includes="**/*.html*/"/>
  231. <fileset dir="${dist.dir}/test/" includes="*.html"/>
  232. </replaceregexp>
  233. <replaceregexp match="^\s*console\.log\([^\)]+\);" replace="" flags="g" byline="true">
  234. <fileset dir="${dist.dir}/demos/" includes="**/*.html*/"/>
  235. </replaceregexp>
  236. <replaceregexp match="^\s*(\u003C)head[^\u003E]*(\u003E)" replace="\1head\2 \1!-- auto --\2 \1link rel='stylesheet' href='../../themes/themeroller/${theme}-theme/${concatenated-themeroller}.css' type='text/css' media='screen'\2 \1link rel='stylesheet' href='../../themes/nokia/ext-theme/${theme}/${resolution}/custom.css' type='text/css' media='screen'\2 \1script src='../../lib/jquery/jquery.js' type='text/javascript' charset='utf-8'\2\1/script\2 \1script src='../../lib/Guarana.js' type='text/javascript' charset='utf-8'\2\1/script\2 \1script type='text/javascript'\2 NOKIA_PATH_JAVASCRIPT = '../../lib/'; NOKIA_PATH_STYLE_ROOT = '../../themes/nokia/base/'; \1/script\2 \1!-- auto --\2" flags="g" byline="true">
  237. <fileset dir="${dist.dir}/demos/" includes="**/*.html*/"/>
  238. </replaceregexp>
  239. <replaceregexp match="^\s*(\u003C)head[^\u003E]*(\u003E)" replace="\1head\2 \1!-- auto --\2 \1link rel='stylesheet' href='../themes/themeroller/${theme}-theme/${concatenated-themeroller}.css' type='text/css' media='screen'\2 \1link rel='stylesheet' href='../themes/nokia/ext-theme/${theme}/${resolution}/custom.css' type='text/css' media='screen'\2 \1script src='../lib/jquery/jquery.js' type='text/javascript' charset='utf-8'\2\1/script\2 \1script src='../lib/Guarana.js' type='text/javascript' charset='utf-8'\2\1/script\2 \1script type='text/javascript'\2 NOKIA_PATH_JAVASCRIPT = '../lib/'; NOKIA_PATH_STYLE_ROOT = '../themes/nokia/base/'; \1/script\2 \1!-- auto --\2" flags="g" byline="true">
  240. <fileset dir="${dist.dir}/test/" includes="*.html"/>
  241. </replaceregexp>
  242. <replaceregexp match="demos/${demofolder}(\\|\/)[^\u003C]+" replace="demos/${demofolder}\\\\${plist.component}\\\\sample_${plist.component}.html" flags="g" byline="true">
  243. <fileset dir="${dist.dir}/" includes="Info.plist"/>
  244. </replaceregexp>
  245. <replaceregexp match="(\n\n\n|\r\n\r\n\r\n)+" replace="" flags="g">
  246. <fileset dir="${dist.dir}/demos/" includes="*/*.html"/>
  247. <fileset dir="${dist.dir}/test/" includes="*/*.html"/>
  248. </replaceregexp>
  249. <echo message="Demos paths fixed."/>
  250. </target>
  251. </project>