build.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="ieat2" basedir="." default="war" xmlns:ivy="antlib:org.apache.ivy.ant">
  3. <property name="lib.dir" value="lib/"/>
  4. <property name="web.dir" value="web/"/>
  5. <property name="test.dir" value="tests/"/>
  6. <property name="conf.dir" value="conf/dev/"/>
  7. <property name="app.name" value="ieat"/>
  8. <property name="app.conf.dir" value="${conf.dir}/app/"/>
  9. <property name="ant.lib" value="${user.home}/.ant/lib"/>
  10. <property name="ant.conf.dir" value="${conf.dir}/ant/"/>
  11. <property prefix="tomcat" file="${ant.conf.dir}/tomcat.properties"/>
  12. <property prefix="build" file="${ant.conf.dir}/build.properties"/>
  13. <property name="build.lib" value="${lib.dir}/war/"/>
  14. <property name="build.warfile"
  15. value="${build.dir}/${app.name}-${build.version}.war"/>
  16. <tstamp>
  17. <format property="build.time" pattern="MM/dd/yyyy hh:mm aa z" />
  18. </tstamp>
  19. <property name="test.halt.failure" value="off"/>
  20. <property name="test.halt.error" value="off"/>
  21. <property name="test.lib" value="${lib.dir}/test/"/>
  22. <property name="test.target.dir" value="${build.dir}/tests"/>
  23. <property name="source.dir" value="src/"/>
  24. <property name="target.dir" value="${build.dir}/${app.name}/WEB-INF/classes"/>
  25. <property prefix="compile" file="${ant.conf.dir}/compile.properties"/>
  26. <property name="compile.lib" value="${lib.dir}/compile"/>
  27. <path id="compile.classpath">
  28. <pathelement location="${target.dir}"/>
  29. <fileset dir="${compile.lib}" includes="*.jar"/>
  30. </path>
  31. <property name="ivy.jar" value="${ant.lib}/ivy.jar"/>
  32. <property name="ivy.dep.file" value="${ant.conf.dir}/ivy.xml" />
  33. <available property="ivy.installed" file="${ivy.jar}"/>
  34. <target name="help" description="Display build help">
  35. <echo>iEat v${build.version}</echo>
  36. <echo>To see list of targets, use ant -p</echo>
  37. </target>
  38. <target name="skip.ivy" description="Do not check dependencies. (Saves laptop battery)">
  39. <property name="ivy.skip" value="true"/>
  40. </target>
  41. <target name="ivy.install" unless="ivy.installed">
  42. <mkdir dir="${ant.lib}"/>
  43. <get dest="${ivy.jar}"
  44. src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar"/>
  45. <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.jar}"/>
  46. <property name="ivy.installed" value="true"/>
  47. </target>
  48. <target name="ivy.tree" depends="ivy.install" description="Show the dependency tree.">
  49. <ivy:dependencytree />
  50. </target>
  51. <target name="ivy.resolve.compile" unless="ivy.skip" depends="ivy.install">
  52. <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" conf="compile"/>
  53. </target>
  54. <target name="ivy.resolve.war" unless="ivy.skip" depends="ivy.install">
  55. <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" conf="war"/>
  56. </target>
  57. <target name="ivy.resolve.test" unless="ivy.skip" depends="ivy.install">
  58. <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact].[ext]" conf="test"/>
  59. </target>
  60. <target name="ivy.resolve.ant" unless="ivy.skip" depends="ivy.install">
  61. <ivy:retrieve pattern="${ant.lib}/[artifact].[ext]" conf="ant"/>
  62. </target>
  63. <target name="test.load" depends="ivy.resolve.ant">
  64. <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
  65. </target>
  66. <target name="deploy.load" depends="ivy.resolve.ant">
  67. <path id="ant.lib.path">
  68. <fileset dir="${ant.lib}" includes="*.jar"/>
  69. </path>
  70. <taskdef resource="org/apache/catalina/ant/antlib.xml"
  71. uri="antlib:org.apache.catalina.ant">
  72. <classpath refid="ant.lib.path"/>
  73. </taskdef>
  74. <taskdef name="deploy"
  75. classname="org.apache.catalina.ant.DeployTask">
  76. <classpath refid="ant.lib.path"/>
  77. </taskdef>
  78. <taskdef name="undeploy"
  79. classname="org.apache.catalina.ant.UndeployTask">
  80. <classpath refid="ant.lib.path"/>
  81. </taskdef>
  82. </target>
  83. <target name="ivy.resolve"
  84. depends="ivy.resolve.compile,ivy.resolve.war,ivy.resolve.ant"
  85. description="Use ivy to resolve compilation dependencies"/>
  86. <target name="compile.server" depends="ivy.resolve.compile" description="Compile server source files">
  87. <mkdir dir="${target.dir}"/>
  88. <javac srcdir="${source.dir}"
  89. verbose="${compile.verbose}"
  90. destdir="${target.dir}"
  91. debug="${compile.debug}"
  92. deprecation="${compile.deprecation}"
  93. optimize="${compile.optimize}"
  94. nowarn="${compile.nowarn}"
  95. includeantruntime="${compile.include.ant}"
  96. bootclasspath="${build.bootstrap.path}"
  97. target="${build.java.version}"
  98. source="${build.java.version}">
  99. <classpath refid="compile.classpath" />
  100. </javac>
  101. </target>
  102. <target name="compile.tests" depends="ivy.resolve.test,compile.server" description="Compile test files">
  103. <mkdir dir="${test.target.dir}"/>
  104. <javac srcdir="${test.dir}"
  105. verbose="${compile.verbose}"
  106. destdir="${test.target.dir}"
  107. debug="${compile.debug}"
  108. deprecation="${compile.deprecation}"
  109. optimize="false"
  110. nowarn="${compile.nowarn}"
  111. includeantruntime="${compile.include.ant}"
  112. bootclasspath="${build.bootstrap.path}"
  113. target="${build.java.version}"
  114. source="${build.java.version}">
  115. <classpath>
  116. <path refid="compile.classpath"/>
  117. <fileset dir="${test.lib}" includes="*.jar"/>
  118. </classpath>
  119. </javac>
  120. </target>
  121. <target name="war" depends="compile.server,ivy.resolve.war"
  122. description="Create application WAR">
  123. <mkdir dir="${build.dir}"/>
  124. <war warfile="${build.warfile}" webxml="${app.conf.dir}/web.xml">
  125. <lib dir="${build.lib}"/>
  126. <fileset dir="web"/>
  127. <classes dir="${target.dir}"/>
  128. <classes dir="${app.conf.dir}">
  129. <exclude name="web.xml"/>
  130. </classes>
  131. </war>
  132. </target>
  133. <target name="test.server"
  134. description="Run all unit tests on server"
  135. depends="compile.server,compile.tests,test.load">
  136. <junit printsummary="yes"
  137. haltonfailure="${test.halt.failure}"
  138. haltonerror="${test.halt.error}">
  139. <classpath>
  140. <path refid="compile.classpath"/>
  141. <fileset dir="${test.lib}" includes="*.jar"/>
  142. <fileset dir="${lib.dir" includes="*.jar"/>
  143. <pathelement location="${test.target.dir}"/>
  144. <pathelement location="conf/test/app/"/>
  145. </classpath>
  146. <batchtest fork="yes">
  147. <fileset dir="${test.dir}">
  148. <include name="**/*.java"/>
  149. </fileset>
  150. <formatter type="plain" usefile="false"/>
  151. </batchtest>
  152. </junit>
  153. </target>
  154. <target name="test" description="Run all tests" depends="test.server">
  155. </target>
  156. <target name="clean" description="Delete build files">
  157. <delete dir="${build.dir}" />
  158. </target>
  159. <target name="clean.full" depends="clean" description="Delete build files and dependencies">
  160. <delete dir="${ivy.jar}"/>
  161. <delete dir="${lib.dir}"/>
  162. <ivy:cleancache/>
  163. </target>
  164. <target name="deploy" depends="war,deploy.load" description="Deploy to tomcat">
  165. <deploy url="http://localhost:8080/manager/text"
  166. username="${tomcat.username}"
  167. password="${tomcat.password}"
  168. update="true"
  169. path="/${app.name}-${build.version}"
  170. war="file:./${build.warfile}" />
  171. </target>
  172. <target name="undeploy" depends="deploy.load" description="Undeploy from tomcat">
  173. <undeploy url="http://localhost:8080/manager/text"
  174. username="${tomcat.username}"
  175. password="${tomcat.password}"
  176. path="/${app.name}-${build.version}"/>
  177. </target>
  178. </project>