Tuesday, September 13, 2011

Ant build script to automate OIM build

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="Builder" default="BuildAll">
 <property name="debug" value="on"/>
 <property name="project.home" value=".."/>
 <property name="src.dir" value="${project.home}/source"/>
 <property name="WebApp.src.dir" value="${project.home}/xlWebApp"/>
 <property name="test.src.dir" value="${project.home}/testsource"/>
 <property name="XellerateFull.src.dir" value="${project.home}/XellerateFull"/>
 <property name="lib.dir" value="${project.home}/lib"/>
 <property name="build.dir" value="${project.home}/build"/>
 <property name="javadocs.dir" value="${build.dir}/javadocs"/>
 <property name="build.classes.dir" value="${build.dir}/classes"/>
 <property name="build.classes.dir.com" value="${build.dir}/classes/com"/>
 <property name="build.deploy.dir" value="${build.dir}/deploy"/>
 <property name="build.deploy.JavaTasks.dir" value="${build.deploy.dir}/JavaTasks"/>
 <property name="build.deploy.ScheduleTask.dir" value="${build.deploy.dir}/ScheduleTask"/>
 <property name="build.deploy.ThirdParty.dir" value="${build.deploy.dir}/ThirdParty"/>
 <property name="build.deploy.EventHandler.dir" value="${build.deploy.dir}/EventHandlers"/>
 <path id="project.class.path">
  <fileset dir="${lib.dir}">
       <include name="**/*.jar"/>
  </fileset>
 </path>
 <target description="Clean All" name="Clean">
  <delete dir="${build.classes.dir.com}" />
  <delete dir="${build.deploy.dir}"/>
  <delete dir="${javadocs.dir}"/>
 </target>

 <target description="Build Java Documentation." name="javadoc">
  <delete dir="${javadocs.dir}"/>
  <mkdir dir="${javadocs.dir}"/>
  <javadoc use="true" doctitle=" Documentation" windowtitle=" JavaDoc" private="true" sourcepath="${src.dir}" packagenames="com.*" destdir="${javadocs.dir}">
   <classpath refid="project.class.path"/>
  </javadoc>
 </target>
 <target name="Initialize" description="Initialize Build Directories" >
  <tstamp/>
  <mkdir dir="${build.deploy.dir}"/>
  <mkdir dir="${build.deploy.JavaTasks.dir}"/>
  <mkdir dir="${build.deploy.ScheduleTask.dir}"/>
  <mkdir dir="${build.deploy.ThirdParty.dir}"/>
  <mkdir dir="${build.deploy.EventHandler.dir}"/>
 </target>

 <target description="ScheduledTask" name="ScheduledTask" depends="Initialize">
  <javac debug="${debug}" deprecation="false" destdir="${build.classes.dir}" srcdir="${src.dir}">
   <classpath refid="project.class.path"/>
   <include name="**/com/xxx/scheduledtasks/**/*.java"/>
  </javac>
  <jar basedir="${build.classes.dir}" jarfile="${build.deploy.ScheduleTask.dir}/ScheduledTasks.jar" >
   <include name="**/com/xxx/scheduledtasks/**/*.class"/>
  </jar> 
 </target>

 <target description="JavaTasks" name="JavaTasks" depends="Initialize">
  <javac debug="${debug}" deprecation="false" destdir="${build.classes.dir}" srcdir="${src.dir}">
   <classpath refid="project.class.path"/>
   <include name="**/com/xxx/javatasks/**/*.java"/>
  </javac>
  <jar basedir="${build.classes.dir}" jarfile="${build.deploy.JavaTasks.dir}/JavaTasks.jar" >
   <include name="**/com/xxx/javatasks/**/*.class"/>
  </jar> 
 </target>

 <target description="EventHandlers" name="EventHandlers" depends="Initialize">
  <javac debug="${debug}" deprecation="false" destdir="${build.classes.dir}" srcdir="${src.dir}">
   <classpath refid="project.class.path"/>
   <include name="**/com/xxx/eventhandlers/**/*.java"/>
  </javac>
  <jar basedir="${build.classes.dir}" jarfile="${build.deploy.EventHandler.dir}/EventHandlers.jar" >
   <include name="**/com/xxx/eventhandlers/**/*.class"/>
  </jar> 
 </target>
 <target description="ThirdParty" name="ThirdParty" depends="Initialize">
  <javac debug="${debug}" deprecation="false" destdir="${build.classes.dir}" srcdir="${src.dir}">
   <classpath refid="project.class.path"/>
   <include name="**/com/xxx/utils/**/*.java"/>
  </javac>
  <jar basedir="${build.classes.dir}" jarfile="${build.deploy.ThirdParty.dir}/Util.jar" >
   <include name="**/com/xxx/utils/**/*.class"/>
  </jar> 
 </target>
 <target description="BuildAll" name="BuildAll" depends="Clean, Initialize, ScheduledTask, JavaTasks, EventHandlers, ThirdParty">
 </target>
</project>

No comments:

Post a Comment