Tuesday, January 4, 2011

Ant script with all features

Here are two Ant scripts having all features:-

<project name="Deepak kumar Modi" default="main" basedir=".">

<property name="src.dir"     value="src"/>
<property name="build.dir"   value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="servlet.jar" value="${src.dir}/../lib/servlet-api.jar"/>

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

<path id="build.path">
<pathelement location="${servlet.jar}"/>
</path>

<target name="prepare" depends="clean">
<mkdir dir="${build.dir}"/>
<mkdir dir="${classes.dir}"/>
</target>

<target name="compile" depends="prepare">    
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref ="build.path"/>
</target>

<target name="main" depends="compile">
<echo message="main target completed.." />
</target>
</project> 

---------------------END of 1----------------------

 <!-- Author Deepak.Modi -->
<project name="ConnectorTool" default="dist" basedir=".">
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="lib" location="lib"/>
<property name="dist"  location="dist"/>

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


<target name="init" depends="clean">
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>

<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" classpathref="project.classpath" />
</target>

<target name="dist" depends="compile"  description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/connectorlib"/>

<copy todir="${dist}/connectorlib" overwrite="true" >
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
</copy>

<copy todir="${dist}" overwrite="true" >
<fileset dir=".">
<include name="*.properties" />
</fileset>
</copy>

<jar jarfile="${dist}/ConnectorTool.jar" basedir="${build}">
<manifest id="MANIFEST.MF">
<attribute name="Built-By" value=" Deepak.Modi"/>
<attribute name="Main-Class" value="com.connector.AutomaticConnector"/>
<attribute name="Class-Path" value=".\connectorlib\classes12.jar .\connectorlib\weblogic.jar .\connectorlib\jmk2api.jar .\connectorlib\xbean_bea.jar"/> 
</manifest>
</jar>
</target>

<target name="clean"  description="clean up" >
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>

</project>


----------------End of 2---------------

No comments:

Post a Comment