রবিবার, ১৫ এপ্রিল, ২০১২


Setup ant file ..... more

Here I write something about build script file......

I used one build.propeties and build.xml file. Both file are in same directory in project folder.

My ant file expect above project structure(that is shown above):


setting information about tomcat server on build.properties:

tomcat.home=/usr/local/tomcat6
deploy.path=${tomcat.home}/webapps
appContext={your project name}

On build.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project name="birth-certificate" default="deploy" basedir=".">

<description>
birth certificate
</description>

<property file="build.properties"/>
<property name="src.dir" location="${basedir}/src"/>
<property name="web.dir" location="${basedir}/web"/>
<property name="lib.dir" location="${basedir}/lib"/>
<property name="props.dir" location="${basedir}/props"/>
<property name="i18n.dir" location="${basedir}/i18n"/>

<property name="build.dir" location="/tmp/build"/>
<property name="classes.dir" location="${build.dir}/WEB-INF/classes"/>
<property name="dist.dir" location="${basedir}/dist"/>

<property name="tomcat.lib" value="${tomcat.home}/lib"/>

<path id="classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>

<fileset dir="${tomcat.lib}">
<include name="*.jar"/>
</fileset>
</path>


<target name="init">
<tstamp>
<format property="build.tstamp" pattern="yyyy-MM-dd HH:mm:ss"/>
</tstamp>
<echo message="Build timestamp: ${build.tstamp}"/>
<mkdir dir="${classes.dir}"/>
</target>

<target name="resources" depends="init" description="prepare deployment resources">
<copy todir="${build.dir}">
<fileset dir="${web.dir}"/>
</copy>

<mkdir dir="${build.dir}/WEB-INF/lib"/>

<copy todir="${build.dir}/WEB-INF/lib">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</copy>

<copy todir="${classes.dir}">
<fileset dir="${props.dir}"/>
<fileset dir="${i18n.dir}"/>
</copy>
</target>


<target name="compile" depends="init">
<javac destdir="${classes.dir}"
classpathref="classpath"
srcdir="${src.dir}"
debug="on"
includeantruntime="false"/>
</target>

<target name="clean">
<delete dir="${build.dir}"/>
</target>

<target name="build" depends="clean, resources, compile"/>

<target name="start">
<exec executable="${tomcat.home}/bin/catalina.sh">
<arg value="start"/>
</exec>
</target>

<target name="stop">
<exec executable="${tomcat.home}/bin/catalina.sh">
<arg value="stop"/>
</exec>
</target>

<target name="remove-deployment">
<delete file="${deploy.path}/${appContext}.war"/>
<delete dir="${deploy.path}/${appContext}"/>
</target>

<target name="undeploy" depends="stop, remove-deployment, start" description="UnDeploy Application"/>

<target name="copy-war" depends="clean, build">
<copy todir="${deploy.path}" file="${dist.dir}/${appContext}.war"/>
</target>

<target name="war" depends="clean, build">
<mkdir dir="${dist.dir}"/>
<war destfile="${dist.dir}/${appContext}.war" webxml="${build.dir}/WEB-INF/web.xml">
<fileset dir="${build.dir}"/>
</war>
</target>

<target name="copy" depends="clean, build">
<copy todir="${deploy.path}/${appContext}">
<fileset dir="${build.dir}"/>
</copy>
</target>

<target name="deploy-war" depends="stop, copy-war, start"/>

<target name="deploy" depends="stop, copy, start"/>


<!--=============================build some extra features===========================-->

<target name="static" description="Copy JSP files and Static contents">
<copy todir="${deploy.path}/${appContext}">
<fileset dir="${web.dir}">
<include name="**/*.jsp"/>
</fileset>
</copy>

<copy todir="${deploy.path}/${appContext}/css">
<fileset dir="${web.dir}/css"/>
</copy>

<copy todir="${deploy.path}/${appContext}/images">
<fileset dir="${web.dir}/images"/>
</copy>

<copy todir="${deploy.path}/${appContext}/js">
<fileset dir="${web.dir}/js"/>
</copy>
</target>


<target name="debug">
<exec executable="${tomcat.home}/bin/catalina.sh">
<arg value="jpda"/>
<arg value="start"/>
</exec>
</target>
</project>

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন