build.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <!--
  2. Ant build script for GeminiHello. Running this script produces a .zip archive
  3. with the following structure:
  4. GeminiHello-yyyy-MM-dd.zip
  5. |~ GeminiHello.war
  6. |~ Source
  7. |~~~ (The current source code of GeminiHello and Gemini.)
  8. -->
  9. <project default="build" name="geminihello">
  10. <target name="compile">
  11. <!-- Import environment variables. -->
  12. <property environment="Environment" />
  13. <!-- Declare other variables which can be overridden in a personalized
  14. build.properties file. -->
  15. <property name="Resin" value="${Environment.RESIN_HOME}" />
  16. <property name="GeminiHello" value="." />
  17. <!-- Compile the source into WEB-INF/classes. -->
  18. <javac srcdir="${GeminiHello}/Source" destdir="${GeminiHello}/Docroot/WEB-INF/classes" includes="**/*">
  19. <classpath>
  20. <pathelement location="${Resin}/lib/javaee-16.jar" />
  21. <pathelement location="${Resin}/lib/resin.jar" />
  22. <fileset dir="${GeminiHello}/Docroot/WEB-INF/lib">
  23. <include name="**/*.jar" />
  24. </fileset>
  25. </classpath>
  26. </javac>
  27. </target>
  28. <target name="build">
  29. <!-- Import environment variables. -->
  30. <property environment="Environment" />
  31. <!-- Declare other variables which can be overridden in a personalized
  32. build.properties file. -->
  33. <property name="Resin" value="${Environment.RESIN_HOME}" />
  34. <property name="GeminiHello" value="." />
  35. <!-- Define some timestamps. These are used to name the zip archive produced
  36. by this script, and to assign a version string for static assets. -->
  37. <tstamp>
  38. <format property="TIMESTAMP_LONG" pattern="yyyy-MM-dd-hh-mm-ss" locale="en" />
  39. <format property="TIMESTAMP_SHORT" pattern="yyyyMMddhhmm" locale="en" />
  40. </tstamp>
  41. <!-- Set the version for this build in GeminiHello-Version.conf. This will
  42. later be copied into the .war file, overriding the placeholder
  43. GeminiHello-Version.conf file there for development. -->
  44. <mkdir dir="temp/version" />
  45. <echo message="StaticsVersion = ${TIMESTAMP_SHORT}" file="temp/version/GeminiHello-Version.conf" append="false" />
  46. <!-- Build geminihello.jar. -->
  47. <mkdir dir="temp/work" />
  48. <javac srcdir="${GeminiHello}/Source" destdir="temp/work" includes="**/*">
  49. <classpath>
  50. <pathelement location="${Resin}/lib/javaee-16.jar" />
  51. <pathelement location="${Resin}/lib/resin.jar" />
  52. <fileset dir="${GeminiHello}/Docroot/WEB-INF/lib">
  53. <include name="**/*.jar" />
  54. </fileset>
  55. </classpath>
  56. </javac>
  57. <jar jarfile="temp/geminihello" basedir="temp/work" />
  58. <delete dir="temp/work" />
  59. <!-- Prepare for minification. -->
  60. <mkdir dir="temp/min" />
  61. <copy todir="temp/min/css">
  62. <fileset dir="${GeminiHello}/Docroot/css" />
  63. </copy>
  64. <copy todir="temp/min/js">
  65. <fileset dir="${GeminiHello}/Docroot/js" />
  66. </copy>
  67. <copy todir="temp/min/jsp">
  68. <fileset dir="${GeminiHello}/Docroot/WEB-INF/jsp" />
  69. </copy>
  70. <!-- Minify CSS files using YUI Compressor. -->
  71. <apply executable="java" parallel="false" force="true" dest="temp/min/css/">
  72. <fileset dir="${GeminiHello}/Docroot/css" includes="**/*.css" />
  73. <arg value="-jar" />
  74. <arg value="${GeminiHello}/Docroot/WEB-INF/lib/yuicompressor-2.4.4.jar" />
  75. <arg value="--type" />
  76. <arg value="css" />
  77. <srcfile />
  78. <arg value="-o" />
  79. <mapper type="identity" />
  80. <targetfile />
  81. </apply>
  82. <!-- Minify JS files using Closure Compiler. -->
  83. <apply executable="java" parallel="false" force="true" dest="temp/min/js/">
  84. <fileset dir="${GeminiHello}/Docroot/js" includes="**/*.js" />
  85. <arg value="-jar" />
  86. <arg value="${GeminiHello}/Docroot/WEB-INF/lib/closure-compiler.jar" />
  87. <arg value="--warning_level=QUIET" />
  88. <arg value="--js" />
  89. <srcfile />
  90. <arg value="--js_output_file" />
  91. <mapper type="identity" />
  92. <targetfile />
  93. </apply>
  94. <!-- Minify JSP files using HtmlCompressor. -->
  95. <!-- If any JSPs are used to render something other than HTML, then
  96. the <fileset> tag below should be modified to exclude them. -->
  97. <apply executable="java" parallel="false" force="true" dest="temp/min/jsp/">
  98. <fileset dir="${GeminiHello}/Docroot/WEB-INF/jsp" includes="**/*.jsp" />
  99. <arg value="-jar" />
  100. <arg value="${GeminiHello}/Docroot/WEB-INF/lib/htmlcompressor-1.1.jar" />
  101. <arg value="--preserve-server-script" />
  102. <arg value="--type" />
  103. <arg value="html" />
  104. <srcfile />
  105. <arg value="-o" />
  106. <mapper type="identity" />
  107. <targetfile />
  108. </apply>
  109. <!-- Build GeminiHello.war. -->
  110. <war destfile="temp/GeminiHello.war" webxml="${GeminiHello}/Docroot/WEB-INF/web.xml">
  111. <zipfileset dir="${GeminiHello}/Docroot" prefix="">
  112. <exclude name="WEB-INF/**/*" />
  113. <exclude name="js/**/*" />
  114. <exclude name="css/**/*" />
  115. </zipfileset>
  116. <zipfileset dir="${GeminiHello}/Docroot/WEB-INF" prefix="WEB-INF">
  117. <include name="*.conf" />
  118. <include name="*.resources" />
  119. <include name="*.tld" />
  120. <include name="*.txt" />
  121. <include name="*.xml" />
  122. <include name="emails/**" />
  123. <include name="jsp/**" />
  124. <include name="lib/**" />
  125. <exclude name="resin.xml" />
  126. <exclude name="GeminiHello-Version.conf" />
  127. </zipfileset>
  128. <zipfileset dir="temp" prefix="WEB-INF/lib">
  129. <include name="*.jar" />
  130. </zipfileset>
  131. <zipfileset dir="temp/min/css" prefix="css" />
  132. <zipfileset dir="temp/min/js" prefix="js" />
  133. <zipfileset dir="temp/min/jsp" prefix="WEB-INF/jsp" />
  134. <zipfileset dir="temp/version" prefix="WEB-INF" />
  135. </war>
  136. <!-- Zip it up. -->
  137. <zip destfile="${GeminiHello}/GeminiHello-${TIMESTAMP_LONG}.zip">
  138. <zipfileset dir="temp">
  139. <include name="*.war" />
  140. </zipfileset>
  141. <zipfileset dir="${GeminiHello}/Source" prefix="Source" />
  142. </zip>
  143. <!-- Delete the temporary directory. -->
  144. <delete dir="temp" />
  145. </target>
  146. </project>