Sunday, February 13, 2011

Simple Ant Script

Simple Ant Script :

            <?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Gpro" basedir="." default="jar" >
      <property name="jar.dir" value="lib" />
      <property name="src.dir" value="src" />
      <property name="classes.dir" value="classes" />
      <property name="lib.dir" value="lib" />
      <property name="config.dir" value="config" />
      <property name="bin.dir" value="bin" />
      <property name="log.dir" value="log" />
     
      <property name="javac.debug" value="off" />
      <property name="javac.args" value="-Xlint"/>
      <property name="project.name" value="Gpro"/>
      <property name="project.name.jar" value="${project.name}.jar" />
      <property name="project.name.zip" value="${project.name}_2.2b.zip" />
      <property name="manifest.name" value="Manifest.txt" />

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

      <path id="compile.classpath">
            <pathelement location="${classes.dir}" />
            <path refid="lib.classpath" />
      </path>

      <!-- Clean -->
      <target name="clean" description="clean Ant output files">
            <!--delete dir="${classes.dir}"/-->
            <delete file="${project.name.zip}"/>
      </target>

      <!-- Compile -->
      <target name="compile"
              description="compile source" depends="clean">
            <mkdir dir="${classes.dir}" />
            <javac srcdir="${src.dir}"
                     destdir="${classes.dir}"
                   debug="${javac.debug}"
                     optimize="on"
                     classpath="${compile.classpath}"
                   memoryMaximumSize="128m"
                   fork="yes">
                  <compilerarg line="${javac.args}" />
                  <src path="${src.dir}" />
            </javac>
      </target>

      <!-- Build JARs -->
      <target name="jar" description="build jar files" depends="clean">
            <mkdir dir="${jar.dir}" />
            <jar destfile="${lib.dir}/${project.name.jar}">
                  <fileset dir="${classes.dir}" />
            </jar>           
      </target>
     
      <!-- Deploy Project -->
      <target name="deploy" description="deploy project" depends="jar">
            <zip  destfile="${project.name.zip}">
                  <fileset dir="." casesensitive="no" defaultexcludes="yes"
                        excludes="**/classes/**
                        **/src/**
                        **/.svn/**
                        **/originalCode/**
                        **/notes/**
                        **/database/**
                        **/.settings/**
                        .project
                        .classpath
                        build.xml"/>
            </zip>
            <!--copy file="${project.name.zip}" todir="..\..\..\.."/-->
      </target>
     
      <!-- Archive Logs -->
      <target name="archive" description="archive logs">
            <tstamp prefix="start"/>
            <delete file="./out/archive/gpro.log.${start.DSTAMP}.zip"/>
            <zip destfile="./out/archive/gpro.log.${start.DSTAMP}.zip" >
                  <fileset dir="out" casesensitive="no" defaultexcludes="yes"
                        excludes="
                        **/*.ser/**
                        **/renderer/**
                        **/archive/**
                        **/all/**"/>
            </zip>
      </target>
     
      <target name="ftp-archive" description="archive logs" depends="archive">
            <ftp server="abc.com"
                   remotedir="."
                   userid="abc"
                   password="gpro01"
                   depends="yes"
                     binary="no">
                <fileset dir="./out/archive" includes="prod.log.${start.DSTAMP}.zip"/>
             </ftp>
      </target>

</project>

No comments:

Post a Comment