Saturday, June 27, 2009

ActiveMQ and One More ANT

I've installed Apache ActiveMQ and started it. To investigate its functionality, I copied the App.java code from the Apache ActiveMQ documentation and saved it. To build and run this code, I use this ANT build file:
<project name="hellomq" default="run" basedir=".">

 <property name="version" value="1.0.0"/>
 <property name="buildfile" value="${ant.project.name}-${version}.jar"/>

 <property name="src"      location="src/main/java"/>
 <property name="build"    location="build"/>
 <property name="dist"     location="dist"/>
 
 <path id="classpath">
  <fileset dir="../../../bin/apache-activemq-5.2.0/" includes="**/*.jar"/>
 </path>

 <target name="clean">
   <delete dir="${build}"/>
   <delete dir="${dist}"/>
 </target>
 
 <target name="init" depends="clean">
  <mkdir dir="${build}"/>
  <mkdir dir="${dist}"/>
 </target>

 <target name="compile" depends="init">
  <javac srcdir="${src}"
      destdir="${build}"
      classpathref="classpath"/>
 </target>
 
 <target name="jar" depends="compile">
   <jar jarfile="${dist}/${buildfile}" basedir="${build}"/>
 </target>

 <target name="run" depends="jar">
  <java fork="true"
   classname="com.hellomq.App">
   <classpath>
    <path refid="classpath"/>
    <path location = "${dist}/${buildfile}"/>
   </classpath>
  </java>
 </target>
 
</project>