build.properties
----------------
app.name =TrackingGadget
app.version = 0.1-dev
build.home = ${basedir}/build
dest.home = ${basedir}/dest
src.home =${basedir}/src/main/java
web.home =${basedir}/Webcontent
lib.dir =${basedir}/Webcontent/WEB-INF/lib
resources.dir =${basedir}/src/main/resources
compile.debug = true
compile.deprecation = false
compile.optimize = true
build.xml:
---------
<project name="TrackingGadget" default="tomcat-start" basedir="."><!--start from "tomcat-start" target-->
<property file="${basedir}/build.properties" /><!-- build properties file specified all folder structure-->
<path id="compile.classpath"><!--set the jar files to classpath-->
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="clean" description="Delete old build and dest directories"><!--before creating folder deleting the previeous folders-->
<echo message="${basedir}" />
<echo message="Delete old build and dest directories." />
<delete dir="${build.home}" />
<delete dir="${dest.home}" />
</target>
<target name="compile" depends="prepare" description="Compile Java sources"><!--compile the all java files-->
<echo message="Compile the java source code." />
<javac srcdir="${src.home}" destdir="${build.home}/WEB-INF/classes" debug="${compile.debug}" deprecation="${compile.deprecation}" optimize="${compile.optimize}">
<classpath refid="compile.classpath" />
</javac>
<copy todir="${build.home}/WEB-INF/classes">
<fileset dir="${src.home}" excludes="**/*.java" />
<fileset dir="${resources.dir}" excludes="**/*.java" />
</copy>
<copydir dest="${build.home}/images" src="${web.home}/images">
</copydir>
<copydir dest="${build.home}/css" src="${web.home}/css">
</copydir>
</target>
<target name="buildWar" depends="clean,compile"><!--build the war file store in to dist folder of the project-->
<echo message="Creating TrackingGadget war file." />
<war warfile="${dest.home}/TrackingGadget-${app.version}.war" webxml="${build.home}/WEB-INF/web.xml">
<fileset dir="${build.home}">
<include name="**/*" />
</fileset>
</war>
</target>
<target name="prepare"><!-- prepare the directory structure-->
<echo message="Creating the required directories." />
<mkdir dir="${build.home}" />
<mkdir dir="${build.home}/WEB-INF" />
<mkdir dir="${build.home}/WEB-INF/classes" />
<mkdir dir="${dest.home}" />
<copy todir="${build.home}">
<fileset dir="${web.home}" excludes="**/struts.xml"/>
</copy>
<mkdir dir="${build.home}/WEB-INF/lib" />
</target>
<target name="stop-tomcat"> <!--stoping the tomcat-->
<echo>---------------------------------------</echo>
<echo>- target - tomcat-stop</echo>
<echo>-</echo>
<echo>- stopping tomcat</echo>
<echo>---------------------------------------</echo>
<java classname="org.apache.catalina.startup.Bootstrap" fork="true">
<classpath path="D:/Tomcat 7.0/bin/bootstrap.jar:D:/Tomcat 7.0/bin/tomcat-juli.jar" />
<jvmarg value="-Dcatalina.home=D:/Tomcat 7.0" />
<arg line="stop" />
</java>
<delete file="D:/Tomcat 7.0/webapps/TrackingGadget-${app.version}.war" /><!--deleting previous war file in tomcat webapps folder-->
<delete dir="D:/Tomcat 7.0/webapps/TrackingGadget-${app.version}" />
<echo message="Clean successfully over"/>
</target>
<target name="tomcat-start" depends="stop-tomcat,buildWar,copywar"><!--starting the tomcat-->
<echo>---------------------------------------</echo>
<echo>- target - tomcat-start</echo>
<echo>-</echo>
<echo>- starting tomcat</echo>
<echo>---------------------------------------</echo>
<java classname="org.apache.catalina.startup.Bootstrap" failonerror="true" fork="true">
<classpath path="D:/Tomcat 7.0/bin/bootstrap.jar:D:/Tomcat 7.0/bin/tomcat-juli.jar" />
<jvmarg value="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager" />
<jvmarg value="-Djava.util.logging.config.file=D:/Tomcat 7.0/conf/logging.properties" />
<jvmarg value="-Dcatalina.home=D:/Tomcat 7.0" />
<jvmarg value="-Dcatalina.base=D:/Tomcat 7.0" />
<jvmarg value="-Djava.io.tmpdir=D:/Tomcat 7.0/temp" />
<arg line="start" />
</java>
</target>
<target name="copywar"><!--copy the war file to tomcat webapps folder-->
<echo message="Creating copy the war war file." />
<fileset dir=".">
<include name="*.war"/>
</fileset>
<copy todir='D:/Tomcat 7.0/webapps' file='${dest.home}/TrackingGadget-${app.version}.war' overwrite="true"/>
</target>
</project>
No comments:
Post a Comment