build.xml

build.xmlファイルより"ant"で一括コンパイルができる

Tomcatのパス\webapps\"strutsアプリフォルダ"\WEB-INF\src
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8.  
  9. http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. -->
  17. <project name="blank" basedir="../" default="all">
  18.  
  19.  
  20. <!-- Local system paths -->
  21. <property name="servlet.jar" value="../../../lib/servlet-api.jar"/>
  22. <property name="distpath.project" value="dist"/>
  23.  
  24.  
  25. <!-- Project settings -->
  26. <property name="project.title" value="Apache Struts Blank "/>
  27. <property name="project.distname" value="blank"/>
  28. <property name="project.version" value="1.3"/>
  29.  
  30.  
  31. <!-- Path settings -->
  32. <property name="doc.path" value="./doc/api"/>
  33. <property name="doc.src" value="./src/java"/>
  34.  
  35.  
  36. <!-- classpath for Struts 1.3 -->
  37. <path id="compile.classpath">
  38. <pathelement path ="lib/commons-beanutils.jar"/>
  39. <pathelement path ="lib/commons-digester.jar"/>
  40. <pathelement path ="lib/struts.jar"/>
  41. <pathelement path ="lib/struts-core-1.3.10.jar"/>
  42. <pathelement path ="${servlet.jar}"/>
  43. <pathelement path ="classes"/>
  44. <pathelement path ="${classpath}"/>
  45. </path>
  46.  
  47.  
  48. <!-- Check timestamp on files -->
  49. <target name="prepare">
  50. <tstamp/>
  51. </target>
  52.  
  53.  
  54. <!-- Copy any resource or configuration files -->
  55. <target name="resources">
  56. <copy todir="classes" includeEmptyDirs="no">
  57. <fileset dir="src/java">
  58. <patternset>
  59. <include name="**/*.conf"/>
  60. <include name="**/*.properties"/>
  61. <include name="**/*.xml"/>
  62. </patternset>
  63. </fileset>
  64. </copy>
  65. </target>
  66.  
  67.  
  68. <!-- Normal build of application -->
  69. <target name="compile" depends="prepare,resources">
  70. <javac srcdir="src/java" destdir="classes">
  71. <classpath refid="compile.classpath"/>
  72. </javac>
  73. </target>
  74.  
  75.  
  76. <!-- Remove classes directory for clean build -->
  77. <target name="clean"
  78. description="Prepare for clean build">
  79. <delete dir="classes"/>
  80. <mkdir dir="classes"/>
  81. </target>
  82.  
  83.  
  84. <!-- Build Javadoc documentation -->
  85. <target name="javadoc"
  86. description="Generate JavaDoc API docs">
  87. <delete dir="./doc/api"/>
  88. <mkdir dir="./doc/api"/>
  89. <javadoc sourcepath="./src/java"
  90. destdir="./doc/api"
  91. classpath="${servlet.jar}"
  92. packagenames="*"
  93. author="false"
  94. private="true"
  95. version="true"
  96. windowtitle="${project.title} API Documentation"
  97. doctitle="<h1>${project.title} Documentation (Version ${project.version})</h1>"
  98. bottom="Copyright &#169; 2002-2005">
  99. <classpath refid="compile.classpath"/>
  100. </javadoc>
  101. </target>
  102.  
  103.  
  104. <!-- Build entire project -->
  105. <target name="project" depends="clean,prepare,compile,javadoc"/>
  106.  
  107.  
  108. <!-- Create binary distribution -->
  109. <target name="dist"
  110. description="Create binary distribution">
  111.  
  112. <mkdir
  113. dir="${distpath.project}"/>
  114. <jar
  115. jarfile="${distpath.project}/${project.distname}.jar"
  116. basedir="./classes"/>
  117. <copy
  118. file="${distpath.project}/${project.distname}.jar"
  119. todir="${distpath.project}"/>
  120.  
  121. <war
  122. basedir="../"
  123. warfile="../../${project.distname}.war"
  124. webxml="web.xml">
  125. <exclude name="**/${distpath.project}/**"/>
  126. </war>
  127. <move file="../../${project.distname}.war" tofile="${distpath.project}/${project.distname}.war" />
  128.  
  129. </target>
  130.  
  131.  
  132. <!-- Build project and create distribution-->
  133. <target name="all" depends="project,dist"/>
  134.  
  135. </project>
  136.  
  137.  
※21行のservlet.jarのパスの場所を設定する(既存の場所と一致しないケースがあるため)
※41行のstruts-core-1.3.10.jarを追加する

「ant compile」とコマンドすればコンパイルを行うことが可能(パッケージ指定していても正しい場所に保存される)





最終更新:2010年07月28日 16:05