[17] | 1 | <project name="My Project" default="help" basedir="."> |
---|
| 2 | <!-- Define the properties used by the build --> |
---|
| 3 | <property name="app.name" value="jregistrate"/> |
---|
| 4 | <property name="tcserver.home" value="/usr/share/tomcat7" /> |
---|
| 5 | <property name="work.home" value="${basedir}/work"/> |
---|
| 6 | <property name="dist.home" value="${basedir}/dist"/> |
---|
| 7 | <property name="src.home" value="${basedir}/src"/> |
---|
| 8 | <property name="web.home" value="${basedir}/web"/> |
---|
| 9 | <property name="lib.home" value="${basedir}/lib"/> |
---|
| 10 | |
---|
| 11 | <target name="help"> |
---|
| 12 | <echo>You can use the following targets:</echo> |
---|
| 13 | <echo> </echo> |
---|
| 14 | <echo> help : (default) Prints this message </echo> |
---|
| 15 | <echo> all : Cleans, compiles, and packages application</echo> |
---|
| 16 | <echo> clean : Deletes work directories</echo> |
---|
| 17 | <echo> compile : Compiles servlets into class files</echo> |
---|
| 18 | <echo> dist : Packages artifacts into a deployable WAR</echo> |
---|
| 19 | <echo></echo> |
---|
| 20 | <echo>For example, to clean, compile, and package all at once, run:</echo> |
---|
| 21 | <echo>prompt> ant all </echo> |
---|
| 22 | </target> |
---|
| 23 | |
---|
| 24 | <!-- Define the CLASSPATH --> |
---|
| 25 | <path id="compile.classpath"> |
---|
| 26 | <fileset dir="${tcserver.home}/bin"> |
---|
| 27 | <include name="*.jar"/> |
---|
| 28 | </fileset> |
---|
| 29 | <pathelement location="${tcserver.home}/lib"/> |
---|
| 30 | <fileset dir="${tcserver.home}/lib"> |
---|
| 31 | <include name="*.jar"/> |
---|
| 32 | </fileset> |
---|
| 33 | <pathelement location="${lib.home}"/> |
---|
| 34 | <fileset dir="${lib.home}"> |
---|
| 35 | <include name="*.jar"/> |
---|
| 36 | </fileset> |
---|
| 37 | </path> |
---|
| 38 | |
---|
| 39 | <target name="all" depends="clean,compile,dist" |
---|
| 40 | description="Clean work dirs, then compile and create a WAR"/> |
---|
| 41 | |
---|
| 42 | <target name="clean" |
---|
| 43 | description="Delete old work and dist directories"> |
---|
| 44 | <delete dir="${work.home}"/> |
---|
| 45 | <delete dir="${dist.home}"/> |
---|
| 46 | </target> |
---|
| 47 | |
---|
| 48 | <target name="prepare" depends="clean" |
---|
| 49 | description="Create working dirs and copy static files to work dir"> |
---|
| 50 | <mkdir dir="${dist.home}"/> |
---|
| 51 | <mkdir dir="${work.home}/WEB-INF/classes"/> |
---|
| 52 | <!-- Copy static HTML and JSP files to work dir --> |
---|
| 53 | <copy todir="${work.home}"> |
---|
| 54 | <fileset dir="${web.home}"/> |
---|
| 55 | </copy> |
---|
| 56 | </target> |
---|
| 57 | |
---|
| 58 | <target name="compile" depends="prepare" |
---|
| 59 | description="Compile Java sources and copy to WEB-INF/classes dir"> |
---|
| 60 | <javac srcdir="${src.home}" |
---|
| 61 | destdir="${work.home}/WEB-INF/classes"> |
---|
| 62 | <classpath refid="compile.classpath"/> |
---|
| 63 | </javac> |
---|
| 64 | <copy todir="${work.home}/WEB-INF/classes"> |
---|
| 65 | <fileset dir="${src.home}" excludes="**/*.java"/> |
---|
| 66 | </copy> |
---|
| 67 | <copy todir="${work.home}/WEB-INF/lib"> |
---|
| 68 | <fileset dir="${lib.home}"/> |
---|
| 69 | </copy> |
---|
| 70 | <copy todir="${work.home}/WEB-INF/db"> |
---|
| 71 | <fileset file="jregistrate.db"/> |
---|
| 72 | </copy> |
---|
| 73 | |
---|
| 74 | </target> |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | <target name="dist" depends="compile" |
---|
| 78 | description="Create WAR file for binary distribution"> |
---|
| 79 | <jar jarfile="${dist.home}/${app.name}.war" |
---|
| 80 | basedir="${work.home}"/> |
---|
| 81 | </target> |
---|
| 82 | |
---|
| 83 | </project> |
---|