Ant Tomcat base build.xml


/ Published in: XML
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <project name="My Project" default="compile" basedir=".">
  2.  
  3. <property name="app.name" value="myapp"/>
  4. <property name="app.path" value="/${app.name}"/>
  5. <property name="app.version" value="0.1-dev"/>
  6. <property name="build.home" value="${basedir}/build"/>
  7. <property name="catalina.home" value="apache-tomcat-dir"/> <!-- UPDATE THIS! -->
  8. <property name="dist.home" value="${basedir}/dist"/>
  9. <property name="docs.home" value="${basedir}/docs"/>
  10. <property name="manager.url" value="http://localhost:8080/manager"/>
  11. <property name="src.home" value="${basedir}/src"/>
  12. <property name="web.home" value="${basedir}/web"/>
  13.  
  14.  
  15. <path id="compile.classpath">
  16.  
  17. <pathelement location="${catalina.home}/common/classes"/>
  18. <fileset dir="${catalina.home}/common/endorsed">
  19. <include name="*.jar"/>
  20. </fileset>
  21. <fileset dir="${catalina.home}/common/lib">
  22. <include name="*.jar"/>
  23. </fileset>
  24. <pathelement location="${catalina.home}/shared/classes"/>
  25. <fileset dir="${catalina.home}/shared/lib">
  26. <include name="*.jar"/>
  27. </fileset>
  28. <fileset dir="${catalina.home}/shared/lib"><!-- extraclasspath -->
  29. <include name="*.jar"/>
  30. </fileset>
  31.  
  32. </path>
  33. <target name="all" depends="clean,compile"
  34. description="Clean build and dist directories, then compile"/>
  35. <target name="clean"
  36. description="Delete old build and dist directories">
  37. <delete dir="${build.home}"/>
  38. <delete dir="${dist.home}"/>
  39. </target>
  40.  
  41.  
  42.  
  43.  
  44. <target name="compile" depends="prepare"
  45. description="Compile Java sources">
  46.  
  47. <!-- Compile Java classes as necessary -->
  48. <mkdir dir="${build.home}/WEB-INF/classes"/>
  49. <javac srcdir="${src.home}"
  50. destdir="${build.home}/WEB-INF/classes"
  51. debug="${compile.debug}"
  52. deprecation="${compile.deprecation}"
  53. optimize="${compile.optimize}">
  54. <classpath refid="compile.classpath"/>
  55. </javac>
  56.  
  57. <!-- Copy application resources -->
  58. <copy todir="${build.home}/WEB-INF/classes">
  59. <fileset dir="${src.home}" excludes="**/*.java"/>
  60. </copy>
  61.  
  62. </target>
  63.  
  64.  
  65.  
  66. <target name="dist" depends="compile,javadoc"
  67. description="Create binary distribution">
  68.  
  69. <!-- Copy documentation subdirectories -->
  70. <mkdir dir="${dist.home}/docs"/>
  71. <copy todir="${dist.home}/docs">
  72. <fileset dir="${docs.home}"/>
  73. </copy>
  74.  
  75. <!-- Create application JAR file -->
  76. <jar jarfile="${dist.home}/${app.name}-${app.version}.war"
  77. basedir="${build.home}"/>
  78.  
  79. <!-- Copy additional files to ${dist.home} as necessary -->
  80.  
  81. </target>
  82.  
  83.  
  84.  
  85. <target name="install" depends="compile"
  86. description="Install application to servlet container">
  87.  
  88. <install url="${manager.url}"
  89. username="${manager.username}"
  90. password="${manager.password}"
  91. path="${app.path}"
  92. war="file://${build.home}"/>
  93.  
  94. </target>
  95.  
  96.  
  97.  
  98. <target name="javadoc" depends="compile"
  99. description="Create Javadoc API documentation">
  100.  
  101. <mkdir dir="${dist.home}/docs/api"/>
  102. <javadoc sourcepath="${src.home}"
  103. destdir="${dist.home}/docs/api"
  104. packagenames="*">
  105. <classpath refid="compile.classpath"/>
  106. </javadoc>
  107.  
  108. </target>
  109.  
  110.  
  111. <target name="list"
  112. description="List installed applications on servlet container">
  113.  
  114. <list url="${manager.url}"
  115. username="${manager.username}"
  116. password="${manager.password}"/>
  117.  
  118. </target>
  119.  
  120.  
  121. <target name="prepare">
  122.  
  123. <!-- Create build directories as needed -->
  124. <mkdir dir="${build.home}"/>
  125. <mkdir dir="${build.home}/WEB-INF"/>
  126. <mkdir dir="${build.home}/WEB-INF/classes"/>
  127.  
  128.  
  129. <!-- Copy static content of this web application -->
  130. <copy todir="${build.home}">
  131. <fileset dir="${web.home}"/>
  132. </copy>
  133.  
  134. <mkdir dir="${build.home}/WEB-INF/lib"/>
  135.  
  136.  
  137. </target>
  138.  
  139. <target name="reload" depends="compile"
  140. description="Reload application on servlet container">
  141.  
  142. <reload url="${manager.url}"
  143. username="${manager.username}"
  144. password="${manager.password}"
  145. path="${app.path}"/>
  146.  
  147. </target>
  148.  
  149.  
  150. <target name="remove"
  151. description="Remove application on servlet container">
  152.  
  153. <remove url="${manager.url}"
  154. username="${manager.username}"
  155. password="${manager.password}"
  156. path="${app.path}"/>
  157.  
  158. </target>
  159.  
  160. </project>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.