<!--

    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="COMMON" basedir="." default="build">

    <!-- IMPORTS -->
    <import file="../../bin/xml/ts.common.props.xml"/>
    
        <target name="init">
          <mkdir dir="${deliverable.bundle.dir}/bin"/>
          <mkdir dir="${deliverable.bundle.dir}/bin/xml"/>
          <mkdir dir="${deliverable.bundle.dir}/bin/xml/impl/glassfish"/>
          <mkdir dir="${deliverable.bundle.dir}/bin/xml/impl/none"/>
          <mkdir dir="${deliverable.bundle.dir}/lib"/>
          <mkdir dir="${deliverable.bundle.dir}/src"/>
          <mkdir dir="${deliverable.bundle.dir}/bin/xml/other"/>
          <mkdir dir="${deliverable.bundle.dir}/classes"/>
          <mkdir dir="${deliverable.bundle.dir}/dist"/>
	</target>

	
        <presetdef name="ts.zip.deliverable">

        <!-- 
          The ts.zip.deliverable task is a presetdef that calls the ant zip task
          with certain preset filesets that are common to all deliverables built
          form the test repository.  Individual deliverables must pass in 
          zipfilesets that are specific to the deliverable being bundled.
        -->

        <zip zipfile="${bundle.dir}/${zip.file}"> 
            <zipfileset dir="${ts.home}/lib" 
                        includes="ant_sun.jar, javatest.jar, tsharness.jar, 
                                  apiCheck.jar, sigtest.jar, tspackager.jar, 
                                  commons-httpclient.jar, commons-logging.jar, 
                                  jdom-1.1.3.jar, jaxen-core-1.0.jar, saxpath.jar, 
                                  jaxen-1.1.6.jar, *-license"
                    prefix="${deliverable.name.token}${deliverable.type}/lib"/> 
            <zipfileset dir="${common.bin.dir}/xml" 
                        includes="ts.*xml"
                 prefix="${deliverable.name.token}${deliverable.type}/bin/xml"/>
            <zipfileset dir="${ts.home}/other" 
                        includes="rebuildable.properties"
                 prefix="${deliverable.name.token}${deliverable.type}/src"/>
            <!--zipfileset dir="${ts.home}/install/${deliverable.dir}/docs" 
                        includes="*ReleaseNotes*.html"
                 prefix="${deliverable.name.token}${deliverable.type}/docs"/-->
            <zipfileset dir="${ts.home}/install/${deliverable.dir}/bin" 
                        includes="**/*"
                 prefix="${deliverable.name.token}${deliverable.type}/bin"/>
            <zipfileset dir="${ts.home}/install/${deliverable.dir}/other" 
                        includes="finder.properties, testsuite.jtt, vehicle.properties"
                 prefix="${deliverable.name.token}${deliverable.type}/src"/>
        </zip>
                 
        </presetdef>
          
        <target name="build" depends="init">
		<copy todir="${deliverable.bundle.dir}/lib" 
                      includeEmptyDirs="no">
			<fileset dir="${ts.home}/lib" includes="ant_sun.jar, 
                        ant-contrib-1.0b3.jar, javatest.jar, tsharness.jar, httpclient-4.5.5.jar,
                        apiCheck.jar,
                        *-license"/>
		</copy>

		<copy todir="${deliverable.bundle.dir}/bin/xml" overwrite="true">
                    <fileset dir="${common.bin.dir}/xml" includes="ts.*xml"/>
                </copy>

        <copy todir="${deliverable.bundle.dir}/bin/xml/other" overwrite="true">
            <fileset dir="${common.bin.dir}/xml/other" includes="*"/>
        </copy>

        <copy todir="${deliverable.bundle.dir}/bin/xml/impl/glassfish" overwrite="true">
            <fileset dir="${common.bin.dir}/xml/impl/glassfish" includes="deploy.xml"/>
        </copy>

        <copy todir="${deliverable.bundle.dir}/bin/xml/impl/none" overwrite="true">
            <fileset dir="${common.bin.dir}/xml/impl/none" includes="*.xml"/>
        </copy>
         
                <copy todir="${deliverable.bundle.dir}/bin" overwrite="true">
                    <fileset dir="${ts.home}/install/${deliverable.dir}/bin" includes="ts.jtx, ts.jtx.platform,ts.jtx.standalone"/>
                </copy>

                <copy todir="${deliverable.bundle.dir}/src" includeEmptyDirs="no">
                    <fileset dir="${ts.home}/src"
			     includes="${tests.pkg.dir}/build.xml,
                                       ${lib.pkg.dir}/build.xml,
                                       ${lib.pkg.dir}/harness/**/*,
                                       ${lib.pkg.dir}/util/**/*,
                                       ${lib.pkg.dir}/javatest/**/*,
                                       ${lib.pkg.dir}/porting/**/*,
                                       ${lib.pkg.dir}/deliverable/*,
                                       ${lib.pkg.dir}/deliverable/tck/*"
                             excludes="${lib.pkg.dir}/porting/TSJMSObjects*,
                                       ${lib.pkg.dir}/harness/ServiceEETes*,
                                       ${lib.pkg.dir}/harness/JCKServiceEETest*,
                                       ${lib.pkg.dir}/harness/EETest*"/>
		</copy>

		<if>
	 	<or>
		    <equals arg1="${deliverable.name}" arg2="J2EE-JMS" casesensitive="false"/>
		    <equals arg1="${deliverable.name}" arg2="J2EE" casesensitive="false"/>
	 	</or>
		<then>
                    <copy todir="${deliverable.bundle.dir}/src" includeEmptyDirs="no">
                        <fileset dir="${ts.home}/src" includes="${lib.pkg.dir}/porting/TSJMSObjects*"/>
		    </copy>
		</then>
		</if>
                
                <copy todir="${deliverable.bundle.dir}/src/${harness.pkg.dir}">
                    <fileset dir="${src.dir}/${harness.pkg.dir}" 
                             includes="rebuildable.properties,
                                       keyword.properties, finder.properties,
                                       commonarchives.properties"/>
                </copy>
                
		<!--copy todir="${deliverable.bundle.dir}/docs" failonerror="false">
			<fileset dir="${ts.home}/install/${deliverable.dir}/docs"
                                 includes="*ReleaseNotes*.html"/>
		</copy-->    
	</target>

</project>
