build.xml 7.2 KB

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