<?xml version="1.0"?>
<!DOCTYPE project [
    <!ENTITY common SYSTEM "file:./build-common.xml">
]>

<!--
  =============================================================================
    Master build file for building all Cactus components.

    $Id: build.xml 366642 2006-01-07 03:13:11Z felipeal $
  =============================================================================
-->
<project name="Master Cactus Build" default="dist" basedir=".">

  <description>
 Cactus Master Build
 ---------------------------------------------------------
 Master build file for building all of the various
 sub-modules that compose the Cactus project, and
 packaging release archives.
  </description>

  <!-- Base directory for all file related operations -->
  <property name="base.dir" location="."/>

  <!-- Include properties and targets common to the different subprojects -->
  &common;

  <!-- Global project properties -->
  <property name="project.name.text" value="Cactus"/>
  <property name="project.name.file" value="cactus"/>

  <!--
     ========================================================================
       Generate the release files for all the Cactus subprojects
     ========================================================================
  -->  
  <target name="dist"
      description="Build the Cactus project for the current J2EE API">

    <ant antfile="download.xml" inheritAll="false"/>

    <ant antfile="framework/build.xml" inheritAll="false" target="dist"/>
    <ant antfile="integration/ant/build.xml" inheritAll="false" target="dist"/>
    <antcall target="dist.eclipse"/>
    <ant antfile="samples/servlet/build.xml" inheritAll="false" target="dist"/>
    <antcall target="dist.jetty"/>
    <antcall target="dist.ejb"/>
    <ant antfile="documentation/build.xml" inheritAll="false" target="dist"/>

  </target>

  <target name="dist.eclipse" if="eclipse.build">
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.webapp/build.xml" 
        inheritAll="false" target="dist"/>
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.runner/build.xml" 
        inheritAll="false" target="dist"/>
  </target>
  
  <target name="dist.jetty" if="j2ee13.available">
    <ant antfile="samples/jetty/build.xml" inheritAll="false" target="dist"/>
  </target>

  <target name="dist.ejb" if="j2ee13.available">
    <ant antfile="samples/ejb/build.xml" inheritAll="false" target="dist"/>
  </target>
    
  <target name="dist.all"
      description="Build the Cactus project for all J2EE APIs">

    <ant antfile="download.xml" inheritAll="false"/>

    <ant antfile="framework/build.xml" inheritAll="false" 
        target="dist">
      <property name="j2ee.jar" value="${j2ee.12.jar}"/>
      <property name="servlet.jar" value="${servlet.22.jar}"/>
      <property name="jsp.jar" value="${servlet.22.jar}"/>
      <property name="clover.enable" value="true"/>
      <property name="env" value="${env}"/>
    </ant>
    <ant antfile="framework/build.xml" inheritAll="false" 
        target="dist">
      <property name="j2ee.jar" value="${j2ee.13.jar}"/>
      <property name="servlet.jar" value="${servlet.23.jar}"/>
      <property name="jsp.jar" value="${servlet.23.jar}"/>
      <property name="clover.enable" value="true"/>
      <property name="env" value="${env}"/>
    </ant>
    <ant antfile="integration/ant/build.xml" inheritAll="false" 
        target="dist">
      <property name="j2ee.jar" value="${j2ee.12.jar}"/>
      <property name="servlet.jar" value="${servlet.22.jar}"/>
      <property name="clover.enable" value="true"/>
      <property name="env" value="${env}"/>
    </ant>
    <ant antfile="integration/ant/build.xml" inheritAll="false" 
        target="dist">
      <property name="j2ee.jar" value="${j2ee.13.jar}"/>
      <property name="servlet.jar" value="${servlet.23.jar}"/>
      <property name="clover.enable" value="true"/>
      <property name="env" value="${env}"/>
    </ant>
    <antcall target="dist.all.eclipse"/>
    <ant antfile="samples/servlet/build.xml" inheritAll="false" 
        target="dist">
      <property name="servlet.jar" value="${servlet.22.jar}"/>
      <property name="j2ee.jar" value=""/>
      <property name="clover.enable" value="true"/>
      <property name="env" value="${env}"/>
    </ant>
    <ant antfile="samples/servlet/build.xml" inheritAll="false" 
        target="dist">
      <property name="servlet.jar" value="${servlet.23.jar}"/>
      <property name="j2ee.jar" value=""/>
      <property name="clover.enable" value="true"/>
      <property name="env" value="${env}"/>
    </ant>
    <ant antfile="samples/jetty/build.xml" inheritAll="false" 
        target="dist">
      <property name="servlet.jar" value="${servlet.23.jar}"/>
      <property name="j2ee.jar" value=""/>
      <property name="clover.enable" value="true"/>
      <property name="env" value="${env}"/>
    </ant>
    <ant antfile="samples/ejb/build.xml" inheritAll="false" 
        target="dist">
      <property name="j2ee.jar" value="${j2ee.13.jar}"/>
      <property name="j2ee-dist.jar" value="${j2ee-dist.13.jar}"/>
      <property name="servlet.jar" value="${servlet.23.jar}"/>
      <property name="clover.enable" value="true"/>
      <property name="env" value="${env}"/>
    </ant>
    <ant antfile="documentation/build.xml" inheritAll="false" 
        target="dist">
      <property name="javadoc.include" value="true"/>
      <property name="clover.enable" value="true"/>
      <property name="env" value="${env}"/>
    </ant>

  </target>

  <target name="dist.all.eclipse" if="eclipse.build">
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.webapp/build.xml" 
        inheritAll="false" target="dist">
      <property name="env" value="${env}"/>
    </ant>
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.runner/build.xml" 
        inheritAll="false" target="dist">
      <property name="j2ee.jar" value="${j2ee.12.jar}"/>
      <property name="servlet.jar" value=""/>
      <property name="env" value="${env}"/>
    </ant>
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.runner/build.xml" 
        inheritAll="false" target="dist">
      <property name="j2ee.jar" value="${j2ee.13.jar}"/>
      <property name="servlet.jar" value=""/>
      <property name="env" value="${env}"/>
    </ant>
  </target>
  
  <!--
     ========================================================================
       Generate the release files for all the Cactus subprojects
     ========================================================================
  -->
  <target name="release"
      depends="clean.all, dist.all"
      description="Generate the Cactus distribution for all J2EE APIs">

    <antcall target="release.j2ee12" inheritall="no">
      <param name="j2ee.dependant" value="true"/>
      <param name="servlet.jar" location="${servlet.22.jar}"/>
      <param name="j2ee.jar" location=""/>
      <param name="release.dir" location="release"/>
    </antcall>
    <antcall target="release.j2ee13" inheritall="no">
      <param name="j2ee.dependant" value="true"/>
      <param name="servlet.jar" location="${servlet.23.jar}"/>
      <param name="j2ee.jar" location=""/>
      <param name="release.dir" location="release"/>
    </antcall>
    <antcall target="release.src"/>

  </target>

  <target name="release.prepare"
      depends="init.properties">

    <mkdir dir="${release.dir}"/>

  </target>

  <target name="release.shared"
      depends="init.properties, release.prepare">

    <!-- Note: We don't bundle the J2EE jar as its license does not
         allow it to be redistributable -->

    <zip destfile="${release.dir}/tmp.zip">
      <zipfileset dir="documentation/dist/doc"
          prefix="${main.release.name}/doc">
        <!-- Remove the Clover reports from the release as they are too big.
             Just leave the front page report but remove the class details -->
        <exclude name="clover-*/org/**"/>
      </zipfileset>
      <zipfileset file="${aspectjrt.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset file="${cactus.ant.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset file="${cactus.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset file="${cargo.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset file="${commons.logging.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset file="${commons.httpclient.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset file="${httpunit.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset file="${junit.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset file="${nekohtml.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset file="${servlet.jar}"
          prefix="${main.release.name}/lib"/>
      <zipfileset dir="${cactus.samples.servlet.bin}"
          prefix="${main.release.name}/samples/servlet">
        <exclude name="lib/**"/>
      </zipfileset>
      <zipfileset dir="framework/web"
          prefix="${main.release.name}/web"/>
      <zipfileset dir="documentation/licenses" prefix="${main.release.name}/licenses"/>
      <zipfileset dir="." prefix="${main.release.name}">
        <include name="ANNOUNCEMENT.txt"/>
      </zipfileset>
    </zip>

  </target>

  <target name="release.j2ee12"
      depends="release.shared">

    <zip destfile="${release.dir}/${main.release.name}.zip">
      <zipfileset src="${release.dir}/tmp.zip"/>
    </zip>
    <delete file="${release.dir}/tmp.zip"/>

  </target>

  <target name="release.j2ee13"
      depends="release.shared">

    <zip destfile="${release.dir}/${main.release.name}.zip">
      <zipfileset src="${release.dir}/tmp.zip"/>
      <zipfileset dir="${cactus.samples.jetty.bin}"
          prefix="${main.release.name}/samples/jetty">
        <exclude name="lib/**"/>
      </zipfileset>
      <zipfileset file="${jstl.jar}"
          prefix="${main.release.name}/samples/servlet/lib"/>
      <zipfileset file="${standard.jar}"
          prefix="${main.release.name}/samples/servlet/lib"/>
      <zipfileset dir="${cactus.samples.ejb.bin}"
          prefix="${main.release.name}/samples/ejb">
        <exclude name="lib/**"/>
      </zipfileset>
      <zipfileset file="${j2ee-dist.13.jar}" prefix="${main.release.name}/lib"/>
      <zipfileset file="${jetty.jar}" prefix="${main.release.name}/lib"/>
      <zipfileset file="${jasper-runtime.jar}" prefix="${main.release.name}/lib"/>
      <zipfileset file="${jasper-compiler.jar}" prefix="${main.release.name}/lib"/>
    </zip>
    <delete file="${release.dir}/tmp.zip"/>

  </target>

  <target name="release.src"
      depends="init.properties">

    <zip zipfile="${release.dir}/${main.release.src.name}.zip">
      <zipfileset dir="." prefix="${main.release.src.name}">
        <exclude name="**/target*/**"/>
        <exclude name="**/dist*/**"/>
        <exclude name="**/release/**"/>
        <exclude name="**/*.log"/>
        <exclude name="**/build.properties"/>
        <exclude name="**/.*/**"/>
        <exclude name="integration/eclipse/**"/>
        <exclude name="**/*.jar"/>
        <exclude name="**/*.zip"/>
      </zipfileset>
    </zip>

  </target>

  <!--
     ========================================================================
       Clean all generated files by all Cactus subprojects.
     ========================================================================
  -->
  <target name="clean"
      depends="init.properties"
      description="Clean the Cactus project for the current J2EE API">

    <delete dir="target-${j2ee.api}"/>
    <ant antfile="framework/build.xml" inheritAll="false" target="clean"/>
    <ant antfile="integration/ant/build.xml" inheritAll="false" target="clean"/>
    <antcall target="clean.eclipse"/>
    <ant antfile="samples/servlet/build.xml" inheritAll="false" target="clean"/>
    <antcall target="clean.jetty"/>
    <antcall target="clean.ejb"/>
    <ant antfile="documentation/build.xml" inheritAll="false" target="clean"/>

  </target>

  <target name="clean.eclipse" if="eclipse.build">
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.webapp/build.xml" 
        inheritAll="false" target="clean"/>
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.runner/build.xml" 
        inheritAll="false" target="clean"/>
  </target>

  <target name="clean.jetty" if="j2ee13.available">
    <ant antfile="samples/jetty/build.xml" inheritAll="false" target="clean"/>
  </target>

  <target name="clean.ejb" if="j2ee13.available">
    <ant antfile="samples/ejb/build.xml" inheritAll="false" target="clean"/>
  </target>
  
  <target name="clean.all"
      depends="init.properties"
      description="Clean the Cactus project for all J2EE APIs">

    <delete dir="${release.dir}"/>
    <delete dir="target-12"/>
    <delete dir="target-13"/>
    <delete>
      <fileset dir="." includes="**/*.log"/>
    </delete>

    <ant antfile="framework/build.xml" inheritAll="false" 
        target="clean">
      <property name="j2ee.jar" value="${j2ee.12.jar}"/>
      <property name="servlet.jar" value="${servlet.22.jar}"/>
      <property name="jsp.jar" value="${servlet.22.jar}"/>
    </ant>
    <ant antfile="framework/build.xml" inheritAll="false" 
        target="clean">
      <property name="j2ee.jar" value="${j2ee.13.jar}"/>
      <property name="servlet.jar" value="${servlet.23.jar}"/>
      <property name="jsp.jar" value="${servlet.23.jar}"/>
    </ant>
    <ant antfile="integration/ant/build.xml" inheritAll="false" 
        target="clean">
      <property name="j2ee.jar" value="${j2ee.12.jar}"/>
      <property name="servlet.jar" value="${servlet.22.jar}"/>
    </ant>
    <ant antfile="integration/ant/build.xml" inheritAll="false" 
        target="clean">
      <property name="j2ee.jar" value="${j2ee.13.jar}"/>
      <property name="servlet.jar" value="${servlet.23.jar}"/>
    </ant>
    <antcall target="clean.all.eclipse"/>
    <ant antfile="samples/servlet/build.xml" inheritAll="false" 
        target="clean">
      <property name="servlet.jar" value="${servlet.22.jar}"/>
      <property name="j2ee.jar" value=""/>
    </ant>
    <ant antfile="samples/servlet/build.xml" inheritAll="false" 
        target="clean">
      <property name="servlet.jar" value="${servlet.23.jar}"/>
      <property name="j2ee.jar" value=""/>
    </ant>
    <ant antfile="samples/jetty/build.xml" inheritAll="false" 
        target="clean">
      <property name="servlet.jar" value="${servlet.23.jar}"/>
      <property name="j2ee.jar" value=""/>
    </ant>
    <ant antfile="samples/ejb/build.xml" inheritAll="false" 
        target="clean">
      <property name="j2ee.jar" value="${j2ee.13.jar}"/>
      <property name="servlet.jar" value="${servlet.23.jar}"/>
    </ant>
    <ant antfile="documentation/build.xml" inheritAll="false" 
        target="clean"/>

  </target>

  <target name="clean.all.eclipse" if="eclipse.build">
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.webapp/build.xml" 
        inheritAll="false" target="clean">
    </ant>
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.runner/build.xml" 
        inheritAll="false" target="clean">
      <property name="j2ee.jar" value="${j2ee.12.jar}"/>
      <property name="servlet.jar" value=""/>
    </ant>
    <ant antfile="integration/eclipse/org.apache.cactus.eclipse.runner/build.xml" 
        inheritAll="false" target="clean">
      <property name="j2ee.jar" value="${j2ee.13.jar}"/>
      <property name="servlet.jar" value=""/>
    </ant>
  </target>

</project>
