<?xml version="1.0" encoding="UTF-8"?>

<!-- Build script for the chapter 11 examples -->
<project name="CMP2 chapter build" default="build-all">

   <property name="src.root" value="src/main/org/jboss/cmp2"/>
   <property name="chapter.dir" value="${build.dir}/cmp2"/>

   <path id="chapter.path">
      <pathelement path="${client.path}" />
      <pathelement location="${lib.dir}/junit.jar" />
      <pathelement location="${lib.dir}/junitejb.jar" />
   </path>

   <target name="prepare">
      <mkdir dir="${chapter.dir}"/>
   </target>

   <target name="config" depends="build-ejb.jar">
      <copy file="${chapter.dir}/cmp2-ex1.jar" todir="${jboss.deploy.dir}"
         overwrite="true" />
      <echo message="Waiting for 5 seconds for deploy..." />
      <sleep seconds="5"/>

      <java fork="yes" classname="junit.textui.TestRunner" taskname="junit" failonerror="true">
         <arg value="org.jboss.cmp2.crimeportal.CrimePortalSetUp"/>
         <sysproperty key="java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory"/>
         <sysproperty key="java.naming.provider.url" value="jnp://localhost:1099"/>
         <sysproperty key="java.naming.factory.url.pkgs" value="org.jboss.naming:org.jnp.interfaces"/>
         <classpath refid="chapter.path"/>
      </java>
   </target>

   <target name="build-all">
      <antcall target="build-ejb.jar"/>
   </target>

   <target name="build-ejb.jar" depends="prepare">
      <jar jarfile="${chapter.dir}/cmp2-ex1.jar">
         <metainf dir="${src.root}">
            <include name="ejb-jar.xml" />
            <include name="jboss.xml" />
            <include name="jbosscmp-jdbc.xml" />
         </metainf>
         <fileset dir="${build.classes.dir}">
            <include name="org/jboss/cmp2/crimeportal/*" />
            <include name="org/jboss/test/util/ejb/*" />
         </fileset>
         <zipfileset src="${lib.dir}/junit.jar" includes="junit/**/*.*"/>
      </jar>
   </target>

   <target name="run-examplereadahead">
      <java fork="yes" classname="junit.textui.TestRunner" taskname="junit" failonerror="true">
         <arg value="org.jboss.cmp2.crimeportal.ReadAheadTest"/>
         <classpath refid="chapter.path"/>
      </java>
   </target>
   <target name="run-exampletest">
      <java fork="yes" classname="junit.textui.TestRunner" taskname="junit" failonerror="true">
         <arg value="org.jboss.cmp2.crimeportal.CrimePortalTest"/>
         <classpath refid="chapter.path"/>
      </java>
   </target>
   <target name="run-examplereadahead-gui">
      <java fork="yes" classname="junit.swingui.TestRunner" taskname="junit" failonerror="true">
         <arg value="org.jboss.cmp2.crimeportal.ReadAheadTest"/>
         <classpath refid="chapter.path"/>
      </java>
   </target>
   <target name="run-exampletest-gui">
      <java fork="yes" classname="junit.swingui.TestRunner" taskname="junit" failonerror="true">
         <arg value="org.jboss.cmp2.crimeportal.CrimePortalTest"/>
         <classpath refid="chapter.path"/>
      </java>
   </target>
</project>
