<?xml version="1.0"?>

<project name="junit examples" default="help" >

  <property name="build.sysclasspath" value="ignore"/>
  <property name="junit.timeout" value="180000"/> <!-- 3 minutes -->
  
  <property file="./build.properties"/>

  <!-- set local properties for this build -->
  <path id="lib.classpath">
      <fileset dir="${lib}">
        <include name="**/*.jar" />
      </fileset>
      <pathelement path="${build}"/>
  </path>

  <target name="help" description="help page">
      <echo message="build.sh &lt;command&gt; where command is:" />
      <echo message="         compile       -- compile the examples code" />
      <echo message="         clobber       -- clean up the whole directory" />
      <echo message="         run.aopc.batch -- run batch aop examples with aopc pre-compiler" />
      <echo message="         run.aop.demo  -- run demo gui for aop cache" />
  </target>

  <!-- set up directory -->
  <target name="init" description="Prepare to build.">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile
    and copy the deployment descriptors into it-->
    <mkdir dir="${build}"/>
    <mkdir dir="${reports}"/>
  </target>

  <target name="clean" description="Clean up compiled classes">
    <delete dir="${build}"/>
    <delete dir="${reports}"/>
  </target>

  <target name="clobber" depends="clean" />

  <!-- compile directory -->
  <target name="compile" depends="init" description="Build unit testing class">
    <javac srcdir="${source}"
           destdir="${build}"
           includes="**/propagation/**"
           debug="true"
           deprecation="true">
      <classpath>
        <path refid="lib.classpath" />
      </classpath>
    </javac>

     <copy todir="${output}/etc">
       <fileset dir="${etc}">
          <include name="**/*"/>
       </fileset>
     </copy>
   
  	  <!-- Use the jboss-aop.xml from the src dir -->
     <copy file="${source}/jboss-aop.xml" 
     	     todir="${output}/etc/META-INF" overwrite="true"/>
  	
  </target>

  <!-- pre-compile directory with aopc -->
  <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="lib.classpath"/>

  <!-- pre-compile directory with annotationc using jdk1.4 -->
  <target name="annoc" depends="compile" description="Annotation precompiler for aop class">
      <taskdef name="annotationc" classname="org.jboss.aop.ant.AnnotationC" classpathref="lib.classpath"/>
      <annotationc compilerclasspathref="lib.classpath" bytecode="true">
         <classpath refid="lib.classpath"/>
         <classpath path="${build}"/>
         <src path="${source}"/>
         <include name="propagation/**/*.java"/>
      </annotationc>
  </target>

   <!-- pre-compile directory with aopc -->
   <target name="aopc" depends="annoc" description="Precompile aop test classes after annoc">
      <aopc compilerclasspathref="lib.classpath" classpathref="lib.classpath" verbose="true">
        <src path="${build}/propagation"/>
        <aoppath path="${output}/etc/META-INF/jboss-aop.xml"/>
        <classpath path="${build}"/>
      </aopc>
   </target>

  <target name="run.aop.example" depends="compile, aopc" description="run standalone server replicator.">
    <java classname="test.propagation.PropagationReplAopTest" fork="yes" >
      <classpath refid="lib.classpath" />
      <classpath path="${build}" />
      <classpath path="${output}/etc" />
    </java>
  </target>

  <target name="run.aop.demo" depends="compile" description="run tree cache demo.">
    <java classname="org.jboss.cache.aop.TreeCacheAopView" fork="yes">
      <jvmarg value="-Xmx128M"/>
      <classpath refid="lib.classpath" />
      <sysproperty key="log4j.configuration" value="file:${output}/etc/log4j.xml"/>
      <classpath path="${output}/etc" />
      <classpath path="${build}" />
    </java>
  </target>


</project>
