<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Build file for Jetspeed -->

<!DOCTYPE project [
    <!ENTITY build-tests-22 SYSTEM "build-tests-22.xml">
    <!ENTITY build-tests-23 SYSTEM "build-tests-23.xml">
]>

<!-- ===========================================================================

    The following properties need to be set in either ./build.properties,
    ${user.home}/.build.properties, a higher level build file, or on the command
    line:
        
        junit.jar             [REQUIRED] The path to the JUnit jar file
        cactus-22.jar         [REQUIRED] The path to the Cactus servlet 2.2
                                         jar file        
        cactus-23.jar         [REQUIRED] The path to the Cactus servlet 2.3
                                         jar file        
        cactus.ant.jar        [REQUIRED] The path to the Cactus custom Ant
                                         tasks jar file

    Additionally, and depending on the servlet engines whith which you wish to
    run your tests, you'll need to set the following properties:

        resin.home.12         [OPTIONAL] Resin 1.2 home directory (required for
                                         the tests_resin_12 target only)

        resin.home.13         [OPTIONAL] Resin 1.3 home directory (required for
                                         the tests_resin_13 target only)
                                         
        tomcat.home.32        [OPTIONAL] Tomcat 3.2 home directory (required
                                         for the tests_tomcat_32 target only)

        tomcat.home.40        [OPTIONAL] Tomcat 4.0 home directory (required
                                         for the tests_tomcat_40 target only)
                                         
        weblogic.home.51      [OPTIONAL] WebLogic 5.1 home directory (required
                                         for the tests_weblogic_51 target only)                 

============================================================================ -->

<project name="Jetspeed" default="jar" basedir="..">

    <!-- Give user a chance to override without editing this file 
         (and without typing -D each time they invoke a target) -->    

    <property file="${user.home}/build.properties" />
    <property file="${user.home}/.build.properties" />
    <property file="build/build.properties" />
  
    <!-- Generic project properties -->

    <property name="project.fullname" value="Jetspeed Portal Implementation"/>
    <property name="project.name" value="jetspeed"/>
    <property name="project.version" value="1.4b1"/>      

    <!-- =================================================================== -->
    <!-- Set the properties related to the source tree                       -->
    <!-- =================================================================== -->

    <!-- Source locations for the build -->    

    <property name="src.dir" value="src"/>
    <property name="src.java.dir" value="${src.dir}/java"/>    
    <property name="src.localization.dir" value="${src.dir}/localization"/>    
    <property name="src.xml.dir" value="${src.dir}/xml"/>
    <property name="lib.dir" value="lib"/>    
    <property name="conf.test.dir" value="build/cactus"/>
    <property name="webapp.dir" value="webapp"/>   
    
    
    <!-- =================================================================== -->
    <!-- Set the properties related to the build area                        -->
    <!-- =================================================================== -->

    <!-- Destination locations for the build (relative to the basedir as -->
    <!-- specified in the 'basedir' attribute of the project tag)        -->

    <property name="build.dir" value="bin"/>  
             
    <property name="out.test.dir" value="${build.dir}/test"/>    
    <property name="build.dest.dir" value="${build.dir}/classes"/>        
    <property name="build.localization.dest.dir" value="${build.dir}/localizationclasses"/>        
    <property name="javadocs.destdir" value="docs/api"/>    
    <property name="release.dir" value="${project.name}-${project.version}/"/>
    <property name="install.war" value="${build.dir}/webapp"/>

    <!-- Miscellaneous settings -->

    <property name="year" value="2002"/>
    <property name="locale.default" value="en"/>
    <property name="ant.home" value="build"/>
    <property name="debug" value="on"/>
    <property name="optimize" value="off"/>
    <property name="deprecation" value="off"/>  

    <!-- Anakia doc settings -->

    <property name="docs.dest" value="docs/site"/>
    <property name="docs.src" value="xdocs"/>  
    <property name="jdom.jar" value="jdom-b7.jar"/>
    <property name="jakarta.site2" value="../jakarta-site2"/>
         
    <!-- =================================================================== -->
    <!-- Builds Classpath                                                    -->
    <!-- =================================================================== -->
    <path id="classpath">
        <fileset dir="build/lib">

            <!-- Everything in the build lib dir -->

            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.dir}">

            <!-- Everything in the project's lib dir -->

            <include name="*.jar"/>
        </fileset>        
    </path>

    <!-- =================================================================== -->
    <!-- Initializes the build.                                              -->
    <!-- =================================================================== -->    
    <target name="init">

        <!-- So that we can use the ${TSTAMP}, ${DSTAMP}, ... time stamps
             in targets, if need be -->
        <tstamp/>

        <echo message="---------- ${project.fullname} ${project.version} ----------"/>
        <echo message=""/>

        <echo message="java.class.path = ${java.class.path}"/>        
        <echo message=""/>
        <echo message="java.home = ${java.home}"/>
        <echo message="ant.home = ${ant.home}"/>
        <echo message="user.home = ${user.home}"/>
        <echo message=""/>
        <echo message="basedir = ${basedir}"/>
        <echo message=""/>        
        <echo message="cactus-22.jar = ${cactus-22.jar}"/>
        <echo message="cactus-23.jar = ${cactus-23.jar}"/>        
        <echo message="cactus.ant.jar = ${cactus.ant.jar}"/>
        <echo message="junit.jar = ${junit.jar}"/>
        <echo message="build.compiler = ${build.compiler}"/>
        <echo message="locale.default = ${locale.default}"/>
                
        <!-- Initialize custom Ant task needed for running the server tests -->
        <taskdef name="runservertests" classname="org.apache.cactus.ant.RunServerTestsTask">
            <classpath>
                <pathelement location="${cactus.ant.jar}"/>                
            </classpath>
        </taskdef>       

        <mkdir dir="${build.dir}"/>
        <mkdir dir="${build.dest.dir}"/>
                  
    </target>

    <!-- ================================================================== -->
    <!-- Displays usage information                                         -->
    <!-- ================================================================== -->
    <target name="usage" description="Displays usage information">
        <echo message="Use -projecthelp to see the available targets"/>
    </target>
        
    <!-- =================================================================== -->
    <!-- Compiles the class files                                            -->
    <!-- =================================================================== -->
    <target 
        name="compile" depends="apis,om,dbpsml" 
        description="Compiles the class files"
    >
        
        <javac 
            classpathref="classpath"
            srcdir="${src.java.dir}/" 
            destdir="${build.dest.dir}" 
            debug="${debug}"
            deprecation="${deprecation}"
            optimize="${optimize}">            
        </javac>

        <!-- Copies non java files that need to be in the classes directory -->
                
        <copy todir="${build.localization.dest.dir}">            
            <fileset dir="${src.localization.dir}">
                <include name="**/*"/>
            </fileset>
        </copy>

        <copy todir="${build.dest.dir}">            
            <fileset dir="${conf.test.dir}">
                <include name="cactus.properties"/>
            </fileset>
        </copy>

        <copy todir="${build.dest.dir}">            
            <fileset dir="${src.java.dir}/">
                <include name="**/*.properties"/>
            </fileset>
        </copy>

        <copy todir="${build.dest.dir}">            
            <fileset dir="${src.java.dir}/">
                <include name="**/*.xml"/>
            </fileset>
        </copy>
        <copy todir="${build.dest.dir}">            
            <fileset dir="${src.java.dir}/">
                <include name="**/*.dtd"/>
            </fileset>
        </copy>

        <copy todir="${build.dest.dir}">            
            <fileset dir="${src.java.dir}/">
                <include name="**/*_${locale.default}.properties"/>
            </fileset>
            <mapper type="glob" from="*_${locale.default}.properties" to="*.properties"/>
        </copy>

    </target>
    
    <!-- =================================================================== -->
    <!-- Creates the jar file                                               -->
    <!-- =================================================================== -->
    <target name="jar" depends="compile" description="Creates the jar file">
        <jar
            jarfile="${build.dir}/${project.name}-${project.version}.jar" 
            basedir="${build.dest.dir}"            
            includes="org/"/>
    </target>
            
    <!-- ================================================================== -->
    <!-- jars the source                                                    -->
    <!-- ================================================================== -->
    <target name="jar-src"
            depends="init"
            description="Generates the jetspeed.{ver}.src.jar file containing source only">
        <jar jarfile="${build.dir}/${project.name}-${project.version}.src.jar"
            basedir="${src.java.dir}" />
    </target>
    
    <!-- =================================================================== -->
    <!-- Generates the project's API documentation                           -->
    <!-- =================================================================== -->
    <target 
        name="javadocs" depends="jar" 
        description="Generates the project's API documentation"
    >
        <mkdir dir="${javadocs.destdir}"/>
        
        <javadoc        
            sourcepath="${src.java.dir}" 
            packagenames="org.apache.jetspeed.*"
            destdir="${javadocs.destdir}"         
            author="true"
            private="false"
            version="true"
            use="true"
            windowtitle="${project.fullname} API"
            doctitle="${project.fullname}"                
            bottom="Copyright &#169; ${year} Apache Software Foundation. All Rights Reserved."
        >
            <classpath refid="classpath"/>
        </javadoc>

    </target>
        
    <!-- =================================================================== -->
    <!-- Builds the Jetspeed release                                         -->
    <!-- =================================================================== -->   
    <target 
        name="release" depends="clean,war_fullrelease" 
        description="Builds the Jetspeed release"
    >
        <delete quiet="true" dir="${release.dir}"/>
        <mkdir dir="${release.dir}"/>
        
        <copy todir="${release.dir}" filtering="off">
            <fileset dir=".">
                <exclude name="*TODO*"/>
                <exclude name="INSTALL-WAR"/>
                <exclude name="bin*"/>
                <exclude name="proposals*"/>          
                <exclude name="**/.#**"/>          
            </fileset>
        </copy>
        
        <zip 
            zipfile="${project.name}-${project.version}-src.zip"
            basedir="${release.dir}/../"
            includes="${project.name}-${project.version}/"
        />

        <delete quiet="true" dir="${release.dir}"/>

    </target>

    <!-- =================================================================== -->
    <!-- Builds the Jetspeed binary release                                  -->
    <!-- =================================================================== -->    
    <target 
        name="release_binary" depends="clean,war_release"
        description="Builds the Jetspeed binary release"
    >
    
        <delete quiet="true" dir="${release.dir}"/>
        <mkdir dir="${release.dir}"/>
        
        <copy file="INSTALL-WAR" tofile="${release.dir}/INSTALL"/>
        <copy file="README" tofile="${release.dir}/README"/>
        <copy file="NOTES" tofile="${release.dir}/NOTES"/>
        <copy file="LICENSE" tofile="${release.dir}/LICENSE"/>
        <copy file="WARNING" tofile="${release.dir}/WARNING"/>

        <copy file="${build.dir}/${project.name}.war" tofile="${release.dir}/${project.name}.war"/>
      
        <zip 
            zipfile="${project.name}-${project.version}-war.zip"
            basedir="${release.dir}/../"
            includes="${project.name}-${project.version}/"
        />

        <delete quiet="true" dir="${release.dir}"/>
        
    </target>          

    <!-- =================================================================== -->
    <!-- Generates Jetspeed jakarta-style site documentation                 -->
    <!-- =================================================================== -->
    <target name="check_for_jdom">
        <available property="jdom.present"
           classname="org.jdom.JDOMException">
            <classpath>
                <pathelement location="${jakarta.site2}/lib/${jdom.jar}"/>
            </classpath>
        </available>
    </target>

    <target 
        name="docs_prepare_error" depends="check_for_jdom" 
        unless="jdom.present"
    >
        <echo>
            The Jakarta-Site2 module is not present! Please check
            to make sure that you have checked it out from CVS.

            &lt;http://jakarta.apache.org/site/jakarta-site2.html&gt;
        </echo>
    </target>

    <target 
        name="docs" depends="docs_prepare_error"
        description="Generates Jetspeed jakarta-style site documentation"
        if="jdom.present"
    >
        <taskdef name="anakia" 
            classname="org.apache.velocity.anakia.AnakiaTask">
            <classpath>
                <fileset dir="${jakarta.site2}/lib">
                    <include name="*.jar"/>
                </fileset>
            </classpath>
        </taskdef>

        <anakia basedir="${docs.src}" destdir="${docs.dest}/"
             extension=".html" style="./site.vsl"
             projectFile="stylesheets/project.xml"
             excludes="**/stylesheets/** empty.xml"
             includes="**/*.xml"
             lastModifiedCheck="true"
             templatePath="${jakarta.site2}/xdocs/stylesheets">
        </anakia>


        <copy todir="${docs.dest}/images" filtering="no">
            <fileset dir="${docs.src}/images">
                <include name="**/*.gif"/>
                <include name="**/*.jpeg"/>
                <include name="**/*.jpg"/>
                <exclude name=".#*"/>
            </fileset>
        </copy>
        <!-- In case we have CSS someday
        <copy todir="${docs.dest}" filtering="no">
            <fileset dir="${docs.src}">
                <include name="**/*.css"/>
                <exclude name=".#*"/>
            </fileset>
        </copy>
        -->
    </target>
    
    <!-- =================================================================== -->
    <!-- Regenerate the castor registry markup Java peers                    -->
    <!-- =================================================================== -->
    <target  name="prepare_apis" depends="init">
        <uptodate 
            property="apis.uptodate" 
            targetfile="${build.dir}/${project.name}-${project.version}.jar"
        >
            <srcfiles dir="${src.xml.dir}" includes="**/*.xsd"/>
        </uptodate>
    </target>
        
    <target name="apis" depends="prepare_apis" unless="apis.uptodate">
        
        <!-- regen jcm -->
         
        <delete quiet="true" >
        <fileset dir="${src.java.dir}/org/apache/jetspeed/xml/api/jcm">
            <exclude name="CVS"/>
            <exclude name="package.html"/>
        </fileset>
        </delete>
        <java classname="org.exolab.castor.builder.SourceGenerator" fork="yes">
            <classpath refid="classpath"/>
            <arg value="-i" />
            <arg value="${src.xml.dir}/jetspeed-portal-content.xsd" />
            <arg value="-f" />
            <arg value="-dest" />
            <arg value="${src.java.dir}" />
            <arg value="-package" />
            <arg value="org.apache.jetspeed.xml.api.jcm" />
        </java>

    <!-- Compile with no deprecation in the API because castor generates (2001/12/17) deprecated SAX1 calls -->
        <javac 
            classpathref="classpath"
            srcdir="${src.java.dir}/org/apache/jetspeed/xml/api" 
            destdir="${build.dest.dir}" 
            debug="${debug}"
            deprecation="off"
            optimize="${optimize}">            
        </javac>
        
    </target>        

    <!-- =================================================================== -->
    <!-- Creates the war file                                                -->
    <!-- =================================================================== -->
    <target name="war" depends="jar" description="Creates the war file">        
                
        <!-- Create the war file -->
        <war warfile="${build.dir}/${project.name}.war"
            webxml="${webapp.dir}/WEB-INF/web.xml">

            <classes dir="${build.dest.dir}">
                <!-- Do not include test files in the runtime jar -->
                <exclude name="**/Test*.*"/>
                <exclude name="**/test*.*"/>

                <!-- Also exclude the test cactus.properties file -->
                <exclude name="cactus.properties"/>
            </classes>
                        
            <lib dir="${lib.dir}">
                <include name="*.jar"/>                
                <exclude name="servlet*.jar"/>
            </lib>            
            
            <fileset dir="${webapp.dir}"> 
                <exclude name="WEB-INF/web.xml"/>
            </fileset>

        </war>       
        
    </target>    


    <!-- =================================================================== -->
    <!-- Installs JetSpeed on a local server                                  -->
    <!-- =================================================================== -->
    <target name="install" depends="jar" description="Installs Jetspeed jars and classes on a local server">
        <copy todir="${install.war}/jetspeed">
            <fileset dir="${webapp.dir}"/> 
        </copy>       
        <copy todir="${install.war}/jetspeed/WEB-INF/lib">
            <fileset dir="${lib.dir}">
                <include name="*.jar"/>                
                <exclude name="servlet*.jar"/>
            </fileset>            
        </copy>       
        <copy todir="${install.war}/jetspeed/WEB-INF/classes">
            <fileset dir="${build.dest.dir}">
                <!-- Do not include test files in the runtime jar -->
                 <exclude name="**/Test*.*"/>
                 <exclude name="**/test*.*"/>

                <!-- Also exclude the test cactus.properties file -->
                <exclude name="cactus.properties"/>
            </fileset>
        </copy>       
    </target>    

    <!-- =================================================================== -->
    <!-- Hot deploys JetSpeed on a local server                                  -->
    <!-- =================================================================== -->
    <target name="hotdeploy"  depends="compile" description="Hot deploys Jetspeed classes on a local server">        
        <copy todir="${deploy.war}/jetspeed/WEB-INF/classes">
            <fileset dir="${build.dest.dir}">
                <!-- Do not include test files in the runtime jar -->
                 <exclude name="**/Test*.*"/>
                 <exclude name="**/test*.*"/>

                <!-- Also exclude the test cactus.properties file -->
                <exclude name="cactus.properties"/>
            </fileset>
        </copy>       
    </target>    
           
    <!-- =================================================================== -->
    <!-- Deploys JetSpeed on a local server                                  -->
    <!-- =================================================================== -->
    <target name="deploy"  depends="compile,war" description="Deploys jetspeed.war on a local server">        
        <!-- Remove app dir from webapp & Copy the war file from of the build dir -->
        <delete dir="${deploy.war}/${project.name}"/> 
        <copy  file="${build.dir}/${project.name}.war" todir="${deploy.war}">
        </copy>
    </target>    
           
    <!-- =================================================================== -->
    <!-- Creates the template war file, one without classes and libs         -->
    <!-- Useful when merging with your jetspeed application                  -->
    <!-- This is how to use it:                                              -->
    <!--  - expand this war into your project build area                     -->
    <!--  - copy over your custom templates/psml/html/images etc             -->
    <!--  - copy over the jetspeed jars and dependancies                     -->
    <!--  - copy over your jars                                              -->
    <!--  - voila - you have a webapp using jetspeed and your code           -->
    <!-- =================================================================== -->
    <target name="war-template" depends="jar" description="Creates the war file">        
                
        <!-- Create the war file -->
        <war warfile="${build.dir}/${project.name}-template.war"
            webxml="${webapp.dir}/WEB-INF/web.xml">

            <fileset dir="${webapp.dir}"> 
                <exclude name="WEB-INF/web.xml"/>
            </fileset>

        </war>       
        
    </target>    
           
    <!-- =================================================================== -->
    <!-- Creates a binary release war file with javadocs API                 -->
    <!-- =================================================================== -->
    <target 
        name="war_release" depends="jar,docs" 
        description="Creates a binary release war file with docs, no javadocs"
    >
        
        <!-- Create the war file -->
        <war warfile="${build.dir}/${project.name}.war"
            webxml="${webapp.dir}/WEB-INF/web.xml">

            <classes dir="${build.dest.dir}">
                <!-- Do not include test files in the runtime jar -->
                <exclude name="**/Test*.*"/>
                <exclude name="**/test*.*"/>

                <!-- Also exclude the test cactus.properties file -->
                <exclude name="cactus.properties"/>
            </classes>           
                        
            <lib dir="${lib.dir}">
                <include name="*.jar"/>                
                <exclude name="servlet*.jar"/>
            </lib>            
            
            <lib dir="${build.dir}">
                <include name="${project.name}-${project.version}.jar"/>                
                <exclude name="servlet*.jar"/>
            </lib>            
            
            <fileset dir="${webapp.dir}"> 
                <exclude name="WEB-INF/web.xml"/>

                <!-- Exclude PSML directories no longer user -->
                <exclude name="WEB-INF/psml/admin/**"/>
                <exclude name="WEB-INF/psml/anon/**"/>
                <exclude name="WEB-INF/psml/test/**"/>
                <exclude name="WEB-INF/psml/turbine/**"/>
                                
                <!-- Exclude files created during testing -->
                <exclude name="WEB-INF/conf/JetspeedSecurity.default"/>
                <exclude name="WEB-INF/conf/JetspeedSecurity.template"/>
                <exclude name="WEB-INF/conf/feed_*.xreg"/>
                <exclude name="WEB-INF/conf/local-manager.xreg"/>
                <exclude name="WEB-INF/conf/local-medias.xreg"/>
                <exclude name="WEB-INF/conf/local-portlets.xreg"/>
                <exclude name="WEB-INF/conf/local-security.xreg"/>
                <exclude name="WEB-INF/conf/local-skins.xreg"/>
            </fileset>
            
            <zipfileset dir="${docs.dest}" 
              prefix="docs">
                <exclude name=".#*"/>
            </zipfileset>

        </war>
    </target>
    
    <!-- =================================================================== -->
    <!-- Creates a full binary release war file with all docs                -->
    <!-- =================================================================== -->
    <target 
        name="war_fullrelease" depends="jar,docs,javadocs" 
        description="Creates a binary release war file with docs and javadocs api"
    >
        
        <!-- Create the war file -->
        <war warfile="${build.dir}/${project.name}.war"
            webxml="${webapp.dir}/WEB-INF/web.xml">

            <lib dir="${lib.dir}">
                <include name="*.jar"/>                
                <exclude name="servlet*.jar"/>
            </lib>            
            
            <lib dir="${build.dir}">
                <include name="${project.name}-${project.version}.jar"/>                
                <exclude name="servlet*.jar"/>
            </lib>            
            
            <fileset dir="${webapp.dir}"> 
                <exclude name="WEB-INF/web.xml"/>
                <exclude name="apidocs/index.html"/>

                <!-- Exclude PSML directories no longer user -->
                <exclude name="WEB-INF/psml/admin/**"/>
                <exclude name="WEB-INF/psml/anon/**"/>
                <exclude name="WEB-INF/psml/test/**"/>
                <exclude name="WEB-INF/psml/turbine/**"/>
                                
                <!-- Exclude files created during testing -->
                <exclude name="WEB-INF/conf/JetspeedSecurity.default"/>
                <exclude name="WEB-INF/conf/JetspeedSecurity.template"/>
                <exclude name="WEB-INF/conf/feed_*.xreg"/>
                <exclude name="WEB-INF/conf/local-manager.xreg"/>
                <exclude name="WEB-INF/conf/local-medias.xreg"/>
                <exclude name="WEB-INF/conf/local-portlets.xreg"/>
                <exclude name="WEB-INF/conf/local-security.xreg"/>
                <exclude name="WEB-INF/conf/local-skins.xreg"/>
            </fileset>
            
            <zipfileset dir="${javadocs.destdir}" 
              prefix="apidocs"/>
            <zipfileset dir="${docs.dest}" 
              prefix="docs">
                <exclude name=".#*"/>
            </zipfileset>

        </war>
    </target>
    
    <!-- =================================================================== -->
    <!-- Run all Cactus tests for Servlet API 2.2                            -->
    <!-- =================================================================== -->
    <target name="tests_all_22"
        depends="tests_resin_12,tests_tomcat_32,tests_orion_14,tests_weblogic_51"
        description="Run all Cactus tests for Servlet API 2.2">
    </target>

    <!-- =================================================================== -->
    <!-- Run all Cactus tests for Servlet API 2.3                            -->
    <!-- =================================================================== -->
    <target name="tests_all_23"
        depends="tests_resin_13,tests_tomcat_40"
        description="Run all Cactus tests for Servlet API 2.3">
    </target>

    <!-- =================================================================== -->
    <!-- Run the client JUnit test cases. This target should not be called   -->
    <!-- directly. It must be called by a test_XXX target (where XXX is the  -->
    <!-- name of the server - see included xml file for different servers)   -->
    <!-- =================================================================== -->
    <target name="tests_22">

        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">

            <classpath>
                <pathelement location="${build.dest.dir}"/>
                <path refid="classpath"/>
                
                <pathelement location="${junit.jar}"/>
                <pathelement location="${cactus-22.jar}"/>                

            </classpath>

            <formatter type="plain" usefile="false"/>            

            <!-- Cactus unit tests -->
            <test name="org.apache.jetspeed.modules.actions.TestJLoginUser"/>
            <test name="org.apache.jetspeed.test.TestBasicSanity"/>
            <test name="org.apache.jetspeed.util.template.TestJetspeedLink"/>
            <test name="org.apache.jetspeed.util.TestMimeType"/>
            <test name="org.apache.jetspeed.test.TestBasicSecurity"/>
        </junit>
    </target>

    <!-- =================================================================== -->
    <!-- Run the client JUnit test cases. This target should not be called   -->
    <!-- directly. It must be called by a test_XXX target (where XXX is the  -->
    <!-- name of the server - see included xml file for different servers)   -->
    <!-- =================================================================== -->
    <target name="tests_23">

        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">

            <classpath>
                <pathelement location="${build.dest.dir}"/>
                <path refid="classpath"/>
                
                <pathelement location="${junit.jar}"/>
                <pathelement location="${cactus-23.jar}"/>                

            </classpath>

            <formatter type="plain" usefile="false"/>            

            <!-- Cactus unit tests -->
            <test name="org.apache.jetspeed.modules.actions.TestJLoginUser"/>
            <test name="org.apache.jetspeed.test.TestBasicSanity"/>
            <test name="org.apache.jetspeed.util.template.TestJetspeedLink"/>
            <test name="org.apache.jetspeed.util.TestMimeType"/>
            <test name="org.apache.jetspeed.test.TestBasicSecurity"/>
        </junit>
    </target>

    <!-- =================================================================== -->
    <!-- Creates a test war file that includes the sample application unit   -->
    <!-- tests                                                               -->
    <!-- =================================================================== -->
    <target name="testwar_22" depends="jar">

        <delete quiet="true" dir="${out.test.dir}"/>

        <!-- Gather libraries -->
        <copy tofile="${lib.dir}/junit.jar" file="${junit.jar}"/>
        <copy tofile="${lib.dir}/cactus-22.jar" file="${cactus-22.jar}"/>

        <!-- Copy the JSP redirector template                                -->
        <copy file="${conf.test.dir}/redirector.jsp"
        tofile="${webapp.dir}/redirector.jsp"/>

        <!-- Make sure the directory for the war exist -->
        <mkdir dir="${out.test.dir}"/>        

        <!-- Create the war file -->
        <war warfile="${out.test.dir}/test.war"
             webxml="${conf.test.dir}/web.xml">

            <classes dir="${build.dest.dir}">
                <exclude name="cactus.properties"/>
            </classes>

            <!-- 
                We need to copy the Cactus and JUnit jars in the war. This is
                because if we just put these jars in the global classpath for
                the Servlet engine, the Cactus jar might not be able to load
                the test case class as it's loadable only by the war classloader.
            -->
            <lib dir="${lib.dir}">
                <include name="*.jar"/>                
                <exclude name="servlet*.jar"/>
            </lib>
            
            <fileset dir="${webapp.dir}">                 
                <exclude name="WEB-INF/web.xml"/>
            </fileset>                      
            
        </war> 
              
        <!-- Undo changes -->
        <delete file="${lib.dir}/junit.jar"/>
        <delete file="${lib.dir}/cactus-22.jar"/>
        <delete file="${webapp.dir}/redirector.jsp"/>

    </target>

    <!-- =================================================================== -->
    <!-- Creates a test war file that includes the sample application unit   -->
    <!-- tests                                                               -->
    <!-- =================================================================== -->
    <target name="testwar_23" depends="jar">

        <delete quiet="true" dir="${out.test.dir}"/>

        <!-- Gather libraries -->
        <copy tofile="${lib.dir}/junit.jar" file="${junit.jar}"/>
        <copy tofile="${lib.dir}/cactus-23.jar" file="${cactus-23.jar}"/>

        <!-- Copy the JSP redirector template                                -->
        <copy file="${conf.test.dir}/redirector.jsp"
        tofile="${webapp.dir}/redirector.jsp"/>

        <!-- Make sure the directory for the war exist -->
        <mkdir dir="${out.test.dir}"/>        

        <!-- Create the war file -->
        <war warfile="${out.test.dir}/test.war"
             webxml="${conf.test.dir}/web.xml">

            <classes dir="${build.dest.dir}">
                <exclude name="cactus.properties"/>
            </classes>

            <!-- 
                We need to copy the Cactus and JUnit jars in the war. This is
                because if we just put these jars in the global classpath for
                the Servlet engine, the Cactus jar might not be able to load
                the test case class as it's loadable only by the war classloader.
            -->
            <lib dir="${lib.dir}">
                <include name="*.jar"/>                
                <exclude name="servlet*.jar"/>
            </lib>
            
            <fileset dir="${webapp.dir}">                 
                <exclude name="WEB-INF/web.xml"/>
            </fileset>                      
            
        </war> 
              
        <!-- Undo changes -->
        <delete file="${lib.dir}/junit.jar"/>
        <delete file="${lib.dir}/cactus-23.jar"/>
        <delete file="${webapp.dir}/redirector.jsp"/>

    </target>

    <!-- =================================================================== -->
    <!-- Run the client JUnit test cases (non-cactus) on the Caching system -->
    <!-- =================================================================== -->
    <target name="unittest-all" depends="unittest, unittest-cache, unittest-security"
            description="Run all unit test"/>

    <!-- =================================================================== -->
    <!-- Run the client JUnit test cases (non-cactus)                        -->
    <!-- =================================================================== -->
    <target name="unittest" depends="compile"
            description="General unit tests">

        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">

            <classpath>
                <pathelement location="${build.dest.dir}"/>
                <path refid="classpath"/>
                <pathelement location="${junit.jar}"/>
                <pathelement location="${hsql.jar}"/>
            </classpath>

            <formatter type="plain" usefile="false"/>            

            <!-- JUnit unit tests -->
            <test name="org.apache.jetspeed.services.psmlmanager.TestMarshalPsml"/>
            <test name="org.apache.jetspeed.services.registry.TestMarshallRegistry"/>
            <test name="org.apache.jetspeed.services.idgenerator.TestIdGenerator"/>
            <test name="org.apache.jetspeed.util.template.TestJetspeedLinkFactory"/> 
            <test name="org.apache.jetspeed.util.rewriter.FrameRewriterTest"/> 
            <test name="org.apache.jetspeed.services.profiler.TestProfilerService"/>
            <test name="org.apache.jetspeed.services.registry.TestRegistryCategories"/>
<!--
            <test name="org.apache.jetspeed.services.registry.TestRegistryPersistence"/> 
-->

        </junit>
    </target>


    <!-- =================================================================== -->
    <!-- Run the client JUnit test cases (non-cactus) on the Caching system -->
    <!-- =================================================================== -->
    <target name="unittest-cache" depends="compile"
            description="Caching subsystem unit tests.  These unit tests generally take a more time to execute then the general unit tests">

        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">

            <classpath>
                <pathelement location="${build.dest.dir}"/>
                <path refid="classpath"/>
                <pathelement location="${junit.jar}"/>
            </classpath>

            <formatter type="plain" usefile="false"/>            

            <!-- JUnit unit tests -->
            <test name="org.apache.jetspeed.services.portletcache.TestTurbineCache"/>
                
        </junit>
    </target>


    <!-- =================================================================== -->
    <!-- Run the client JUnit test cases (non-cactus)                        -->
    <!-- =================================================================== -->
    <target name="unittest-security" 
	         depends="unittest-security-turbine, unittest-security-user, unittest-security-registry"
            description="Security unit test for all implementations"/>

    <!-- =================================================================== -->
    <!-- Run the client JUnit test cases (non-cactus)                        -->
    <!-- =================================================================== -->
    <target name="unittest-security-registry" depends="compile"
            description="Registry security unit test">

        <!-- Set properties for testing. This must be done in 2 steps and a temp file -->
        <copy file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.template" tofile="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.temp" overwrite="yes">
          <filterset>
            <filter token="services.PortalAccessController.classname" value="org.apache.jetspeed.services.security.registry.RegistryAccessController"/>
          </filterset>
        </copy>
        <copy file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.temp" tofile="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.properties" overwrite="yes">
          <filterset>
            <filtersfile file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.default"/>
          </filterset>
        </copy>
        <delete file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.temp" failonerror="false" quiet="true" verbose="false"/>

        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
            <classpath>
                <pathelement location="${build.dest.dir}"/>
                <path refid="classpath"/>
                <pathelement location="${junit.jar}"/>
                <pathelement location="${hsql.jar}"/>
            </classpath>

            <formatter type="plain" usefile="false"/>            

            <!-- JUnit unit tests -->
            <test name="org.apache.jetspeed.services.security.registry.TestAccessController"/>

        </junit>
    </target>

    <target name="unittest-security-user" depends="compile"
            description="User security unit test">

        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
            <classpath>
                <pathelement location="${build.dest.dir}"/>
                <path refid="classpath"/>
                <pathelement location="${junit.jar}"/>
                <pathelement location="${hsql.jar}"/>
            </classpath>

            <formatter type="plain" usefile="false"/>            

            <!-- JUnit unit tests -->

            <test name="org.apache.jetspeed.services.security.TestUserManagement"/>
            <test name="org.apache.jetspeed.services.security.TestPortalAuthentication"/> 

            <test name="org.apache.jetspeed.services.security.TestRoleManagement"/> 
            <test name="org.apache.jetspeed.services.security.TestGroupManagement"/> 

            <test name="org.apache.jetspeed.services.security.TestPermissionManagement"/> 

            <test name="org.apache.jetspeed.services.security.TestSecurityCache"/> 

        </junit>
    </target>

    <!-- =================================================================== -->
    <!-- Run the client JUnit test cases (non-cactus)                        -->
    <!-- =================================================================== -->
    <target name="unittest-security-turbine" depends="compile"
            description="Turbine security unit test">

        <!-- Set properties for testing. This must be done in 2 steps and a temp file -->
        <copy file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.template" tofile="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.temp" overwrite="yes">
          <filterset>
            <filter token="services.PortalAccessController.classname" value="org.apache.jetspeed.services.security.turbine.TurbineAccessController"/>
          </filterset>
        </copy>
        <copy file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.temp" tofile="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.properties" overwrite="yes">
          <filterset>
            <filtersfile file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.default"/>
          </filterset>
        </copy>
        <delete file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.temp" failonerror="false" quiet="true" verbose="false"/>

        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">

            <classpath>
                <pathelement location="${build.dest.dir}"/>
                <path refid="classpath"/>
                <pathelement location="${junit.jar}"/>
                <pathelement location="${hsql.jar}"/>
            </classpath>

            <formatter type="plain" usefile="false"/>            

            <!-- JUnit unit tests -->
            <test name="org.apache.jetspeed.services.security.turbine.TestAccessController"/>

        </junit>
    </target>


    <!-- =================================================================== -->
    <!-- Rebuilds everything                                                 -->
    <!-- This is a little quicker than "clean; build" because there is no    -->
    <!-- second JVM bootup.                                                  -->
    <!-- =================================================================== -->
    <target name="rebuild" depends="clean,jar" 
            description="Rebuilds everything"
    />

    <!-- =================================================================== -->
    <!-- Cleans up the distribution                                          -->
    <!-- =================================================================== -->
    <target name="clean" description="Cleans up the distribution"
    >
        <delete quiet="true">
        <fileset dir="${build.dir}">
            <!-- Everything in the build lib dir -->
            <exclude name="CVS"/>
        </fileset>
        <fileset dir="${src.java.dir}/org/apache/jetspeed/xml/api/jcm">
            <exclude name="CVS"/>
            <exclude name="**.html"/>
            <include name="**.java"/>
        </fileset>
        </delete>

        <!-- Set JetspeedSecurity propery file to it's default values -->
        <copy file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.template" tofile="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.properties" overwrite="yes">
          <filterset>
            <filtersfile file="${webapp.dir}/WEB-INF/conf/JetspeedSecurity.default"/>
          </filterset>
        </copy>
    </target>

	 <!-- =================================================================== -->
	 <!-- Object Model                                                        -->
	 <!-- =================================================================== -->
		<target name="check_om">
		  <uptodate property="omBuild.notRequired"  targetfile="./src/sql/security-schema.sql">
		    <srcfiles dir= "./build/torque/schema" includes="security-schema.xml"/>
		    <srcfiles dir= "./build/torque" includes="build.properties"/>
		  </uptodate>
		</target>
		
		<target name="om" depends="check_om"
		        unless="omBuild.notRequired"
		        description="Generate Object Model sources">
		
		  <ant antfile="build.xml" dir="./build/torque">
		      <property name="build.properties" value="build.properties"/>
		  </ant>
		
		</target>

	 <!-- =================================================================== -->
	 <!-- Object Model                                                        -->
	 <!-- =================================================================== -->
		<target name="check_dbpsml">
		  <uptodate property="omBuild.notRequired2"  targetfile="./src/sql/dbpsml-schema.sql">
		    <srcfiles dir= "./build/torque/schema" includes="dbpsml-schema.xml"/>
		    <srcfiles dir= "./build/torque" includes="dbpsml.properties"/>
		  </uptodate>
		</target>
		
		<target name="dbpsml" depends="check_dbpsml"
		        unless="omBuild.notRequired2"
		        description="Generate DBPSML Object Model sources">
		
		  <ant antfile="build.xml" dir="./build/torque">
		      <property name="build.properties" value="dbpsml.properties"/>
		  </ant>
		
		</target>

    <!-- =================================================================== -->
    <!-- Include the usage target and the test targets for the different     -->
    <!-- servlet engine                                                      -->
    <!-- =================================================================== -->
    
    &build-tests-22;
    &build-tests-23;
    
</project>

