<!--

    Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License v. 2.0, which is available at
    http://www.eclipse.org/legal/epl-2.0.

    This Source Code may also be made available under the following Secondary
    Licenses when the conditions for such availability set forth in the
    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
    version 2 with the GNU Classpath Exception, which is available at
    https://www.gnu.org/software/classpath/license.html.

    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<project name="SecurityAPI TCK" default="usage">

    <!-- IMPORTS -->
    <import file="xml/ts.top.import.xml" optional="true"/>
    <import file="../../../bin/xml/ts.top.import.xml" optional="true"/>

    <property name="all.test.dir" value="
              com/sun/ts/tests/securityapi/ham,
    		  com/sun/ts/tests/securityapi/idstore,
              com/sun/ts/tests/securityapi/securitycontext"/>

    <target name="build.all.tests" >
        <echo message="Test Dirs:${all.test.dir}"/>
        <dosubdirs srcdir="${ts.home}/src" includes="${all.test.dir}" todo="build"/>
    </target>

    <target name="translatepath">
        <translatepath propname="web.home"/>
    </target>


    <!-- 
         this is used to setup the webserver to support running of security
         tests which are contained in com/sun/ts/tests/securityapi/spec/security
      -->
    <target name="config.security" >
        <ant antfile="s1as.xml" dir="${ts.home}/bin/xml/impl/${impl.vi}" 
             target="add.cts.users"/>            
        <ant antfile="s1as.xml" dir="${ts.home}/bin/xml/impl/${impl.vi}" 
             target="add.cert"/>
    </target>


    <target name="deploy.all" description="Deploy all archives.">
        <echo message="javaee.level: ${javaee.level}" />
        <property name="pkg.dir" value="com/sun/ts/tests/securityapi"/>
        <ant antfile="build.xml" dir="${ts.home}/src/com/sun/ts/tests/securityapi" target="deploy"/>    	
    </target>

    <target name="tslib.clean" depends="translatepath">
        <delete failonerror="false">
            <fileset dir="${class.dir}">
                <include name="${lib.pkg.dir}/deliverable/securityapi/**"/>
                <include name="${lib.pkg.dir}/deliverable/tck/**"/>
                <include name="${provider.dir}/"/>
            </fileset>
        </delete>
        <delete failonerror="false" file="${lib.dir}/${tslib.name}.jar"/>
    </target>

    <target name="tslib.compile" depends="tslib.clean, bind.dtds">
        <echo message="Classpath:${ts.classpath}"/>
        <ts.javac 
                includes="${lib.pkg.dir}/deliverable/securityapi/**,
                  ${lib.pkg.dir}/deliverable/tck/**,
                  ${lib.pkg.dir}/porting/**/*.java,
                  ${lib.pkg.dir}/implementation/sun/common/**,
                  ${lib.pkg.dir}/implementation/sun/javaee/SunRIHttpsURLConnection.java,
                  ${provider.dir}/**,
                  com/sun/ts/tests/common/vehicle/VehicleClient.java,
                  com/sun/ts/tests/common/vehicle/VehicleRunnerFactory.java,
                  com/sun/ts/tests/common/vehicle/EmptyVehicleRunner.java,
                  com/sun/ts/tests/common/vehicle/VehicleRunnable.java"
                excludes="${lib.pkg.dir}/implementation/sun/javaee/SunRIDeploy**,
                  ${lib.pkg.dir}/porting/TSJMS*.java,
        ${lib.pkg.dir}/porting/TSDeployment*.java">
            <classpath>
                <pathelement path="${ts.lib.classpath}" />
            </classpath>
        </ts.javac>
    </target>


    <target name="tslib" depends="tslib.compile">
        <tstamp/>
        <delete failonerror="true" file="${lib.dir}/${tslib.name}.jar"/>
        <ts.lib.jar>
            <include name="${lib.pkg.dir}/deliverable/securityapi/**"/>
            <include name="${lib.pkg.dir}/deliverable/tck/**"/>
            <include name="${lib.pkg.dir}/implementation/sun/common/**"/>
            <include name="${lib.pkg.dir}/implementation/sun/javaee/**"/>
            <include name="com/sun/ts/tests/common/vehicle/VehicleClient.class"/>
            <include name="com/sun/ts/tests/common/vehicle/VehicleRunnerFactory.class"/>
            <include name="com/sun/ts/tests/common/vehicle/EmptyVehicleRunner.class"/>
            <include name="com/sun/ts/tests/common/vehicle/VehicleRunnable.class"/>
        </ts.lib.jar>
    </target>

     <target name="init.derby">
             <ant antfile="./initdb.xml" target="init.derby"/>
     </target>

    <target name="init.javadb" >
            <antcall target="init.derby"/>
    </target>

    <target name="init.db2">
            <ant antfile="./initdb.xml" target="init.db2"/>
    </target>

    <target name="init.mssqlserver">
            <ant antfile="./initdb.xml" target="init.mssqlserver"/>
    </target>

    <target name="init.mysql">
            <ant antfile="./initdb.xml" target="init.mysql"/>
     </target>

    <target name="init.oracle">
            <ant antfile="./initdb.xml" target="init.oracle"/>
    </target>


     <target name="init.postgresql" >
         <ant antfile="./initdb.xml" target="init.postgresql"/>
    </target>

    <target name="init.pointbase">
            <ant antfile="./initdb.xml" target="init.pointbase"/>
    </target>

    <target name="init.sybase">
            <ant antfile="./initdb.xml" target="init.sybase"/>
    </target>

    <!-- these targets are needed for configuring the VI and RI implementations for WebSocoket tests -->
    <target name="config.vi">
          <ant antfile="${bin.dir}/xml/impl/${impl.vi}/config.vi.xml" target="config.vi" />
    </target>

    <target name="clean.vi">
         <ant antfile="${bin.dir}/xml/impl/${impl.vi}/config.vi.xml" target="clean.vi" />
    </target>

    <target name="init.ldap">
      <if>
         <equals arg1="${ldap.server}" arg2="unboundid" />
         <then>
             <ant antfile="initldap.xml" dir="${bin.dir}" target="init.unboundid"/>
         </then>
       </if>
    </target>

</project>

