<!--

    Copyright (c) 2018, 2021 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" basedir="." default="build">

    <!-- IMPORTS -->
	<import file="../../bin/xml/ts.common.props.xml"/>

	<property name="deliverable.version"  value="3.0"/>
        <property name="deliverable.tck.version"  value="3.0.0"/>


	<target name="init">
		<mkdir dir="${deliverable.bundle.dir}/bin"/>
		<mkdir dir="${deliverable.bundle.dir}/bin/certificates"/>
		<mkdir dir="${deliverable.bundle.dir}/classes"/>
		<mkdir dir="${deliverable.bundle.dir}/dist"/>
		<mkdir dir="${deliverable.bundle.dir}/lib/dtds"/>
		<mkdir dir="${deliverable.bundle.dir}/src"/>
		<mkdir dir="${deliverable.bundle.dir}/src/com/sun/ts/lib/porting"/>
        <mkdir dir="${deliverable.bundle.dir}/sql"/>
	</target>

	<target name="copyinstall">
		<copy todir="${deliverable.bundle.dir}/bin" includeEmptyDirs="no">
			<fileset dir="${ts.home}/install/${deliverable.name.lower}/bin"
					 includes="**/*"
					 excludes="**/workspace.xml"/>
		</copy>
		<copy todir="${deliverable.bundle.dir}/bin/certificates" includeEmptyDirs="no">
			<fileset dir="${ts.home}/install/securityapi/bin/certificates"
					 includes="**/*"/>
		</copy>
		<copy todir="${deliverable.bundle.dir}/lib" includeEmptyDirs="no">
			<fileset dir="${ts.home}/lib"
					 includes="jdom-1.1.3.jar, jaxen-core-1.0.jar, saxpath.jar, jaxb-xjc.jar, tsharness.jar, securityapitck.jar, javatest.jar, ant.jar, commons-logging-1.1.3.jar, commons-io-2.4.jar, commons-lang3-3.3.2.jar, commons-codec-1.9.jar, commons-collections-3.2.1.jar, commons-httpclient-3.1.jar, cssparser-0.9.25.jar, securityapi_idstore_ldapserver.jar, unboundid-ldapsdk.jar, httpclient-4.5.5.jar, httpcore-4.4.9.jar, htmlunit-2.15.jar, htmlunit-core-js-2.15.jar, httpmime-4.5.5.jar, nekohtml-1.9.21.jar, xercesImpl-2.11.0.jar, xalan-2.7.2.jar, serializer-2.7.2.jar, sac-1.3.jar, jaxen-1.1.6.jar, xml-apis-1.4.01.jar, jakarta.activation-api.jar, jaxb-api.jar, jaxb-core.jar, jaxb-xjc.jar" />
	
	
		
		</copy>
		<copy todir="${deliverable.bundle.dir}/src">
			<fileset dir="${ts.home}/install/${deliverable.name.lower}/other"
					 includes="**/*"/>
		</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/xml/impl/glassfish"
			  overwrite="true">
			<fileset dir="${common.bin.dir}/xml/impl/glassfish"
					 includes="*.xml"/>
		</copy>

		<copy todir="${deliverable.bundle.dir}/bin/xml/impl/glassfish/templates"
			  overwrite="true">
			<fileset dir="${common.bin.dir}/xml/impl/glassfish/templates"
					 includes="*.template*"/>
		</copy>
		<copy todir="${deliverable.bundle.dir}/sql" includeEmptyDirs="no">
			<fileset dir="${ts.home}/sql"
                             		 includes="**/*securityapi.sql"/>
                </copy>

                <!--copy todir="${deliverable.bundle.dir}/docs" includeEmptyDirs="no">
                        <fileset dir="${ts.home}/install/${deliverable.name.lower}/docs"
                                 includes="assertions/*.html, *-ReleaseNotes.html" />
                </copy-->
               <!-- NOTICE will be EPL or EFTL specific: TBD-->
               <!--copy todir="${deliverable.bundle.dir}" includeEmptyDirs="no">
                   <fileset dir="${ts.home}" includes="NOTICE" />
               </copy-->
		<!--copy tofile="${deliverable.bundle.dir}/LICENSE.md" file="${ts.home}/${licensefile}">
	  </copy-->
	</target>

	<target name="build" depends="init">
		<antcall target="copyinstall"/>

        <!-- the classes directory -->
		<copy todir="${deliverable.bundle.dir}/classes" includeEmptyDirs="no">
			<fileset dir="${ts.home}/classes"
					 includes="com/sun/ts/tests/securityapi/**/*.class,
                     com/sun/ts/tests/common/webclient/**/*.class,
                     com/sun/ts/lib/porting/TSURL.class,
                     com/sun/ts/lib/porting/TSURLInterface.class,
                     com/sun/ts/lib/deliverable/tck/*.class,
                     com/sun/ts/lib/implementation/sun/javaee/*.class"

                     excludes="com/sun/ts/tests/signaturetest/*.txt,
                         com/sun/ts/tests/signaturetest/*.sh,
                         com/sun/ts/tests/signaturetest/README" />
		</copy>

                <!-- the lib/dtds directory -->
		<copy todir="${deliverable.bundle.dir}/lib/dtds" includeEmptyDirs="no">
			<fileset dir="${ts.home}/lib/dtds" includes="web-app*"/>
		</copy>

                <!-- include schemas needed for the technology -->
		<copy todir="${deliverable.bundle.dir}/lib/schemas" includeEmptyDirs="no">
			<fileset dir="${ts.home}/lib/schemas"
					 includes="web-app*,
                     XMLSchema.xsd, xml.xsd,
            j2ee_web_services_client_1_1.xsd"/>
		</copy>

        <!-- copy the commons-httpclient and dependent JARs -->
		<!--copy todir="${deliverable.bundle.dir}/lib" includeEmptyDirs="no">
			<fileset dir="${ts.home}/lib" includes="commons-*.jar" />
		</copy-->

        <!-- the war files in the dist directory -->
		<copy todir="${deliverable.bundle.dir}/dist" includeEmptyDirs="no">
			<fileset dir="${ts.home}/dist" includes="com/sun/ts/tests/securityapi/**/*.war, com/sun/ts/tests/securityapi/**/*.sun-web.xml"
					 excludes="**/deploy/,**/platform/,
                     **/spec/crosscontext/*"/>
		</copy>

        <!-- the specific deliverable source directories -->
		<copy todir="${deliverable.bundle.dir}/src" includeEmptyDirs="no">
			<fileset dir="${ts.home}/src"
	          includes="com/sun/ts/tests/securityapi/**/*,
                     com/sun/ts/tests/common/webclient/**/*"
                  excludes="**/.svn/*,
                         com/sun/ts/tests/signaturetest/*Record*,
                         com/sun/ts/tests/signaturetest/*record*"/>
		</copy>

                <!--
		<copy todir="${deliverable.bundle.dir}/src/com/sun/ts/tests/signaturetest/signature-repository/"
			  includeEmptyDirs="no">
			<fileset dir="${ts.home}/src/com/sun/ts/tests/signaturetest/signature-repository/"
					 includes="javax.servlet.sig_2.5*" />
		</copy>
                -->

        <!-- the com/sun/ts/lib file -->
		<copy file="${ts.home}/src/com/sun/ts/lib/build.xml"
			  todir="${deliverable.bundle.dir}/src/com/sun/ts/lib"/>

        <!-- the com/sun/ts/lib/porting directory -->
		<copy todir="${deliverable.bundle.dir}/src/com/sun/ts/lib/porting"
			  includeEmptyDirs="no">
			<fileset dir="${ts.home}/src/com/sun/ts/lib/porting"
					 includes="TSDeploymentInterface.java,
                     TSDeploymentException.java,
            TSURLInterface.java, TSURL.java"/>
		</copy>

        <!-- the com/sun/ts/lib/implementation/sun/common file -->
		<copy file="${ts.home}/src/com/sun/ts/lib/implementation/sun/common/SunRIURL.java"
			  todir="${deliverable.bundle.dir}/src/com/sun/ts/lib/implementation/sun/common"/>

        <!-- the com/sun/ts/lib/implementation/sun/javaee directory -->
		<copy todir="${deliverable.bundle.dir}/src/com/sun/ts/lib/implementation/sun/javaee"
			  includeEmptyDirs="no">
			<fileset dir="${ts.home}/src/com/sun/ts/lib/implementation/sun/javaee"
					 includes="ManualDeployment.java,SunRIDeployment.java"/>
		</copy>

		<delete quiet="true">
			<fileset dir="${deliverable.bundle.dir}/lib"
					 includes="*jaxb*"/>
		</delete>

		<copy file="${ts.home}/pom-bundle.xml"
              tofile="${deliverable.bundle.dir}/pom.xml"/>

		<!--antcall target="mvn"/-->
        <!--
		  <antcall target="create.doc.bundle"/>
        -->
	</target>
        <target name="mvn">
         <exec dir="${ts.home}/user_guides/${deliverable.dir}" executable="mvn">
         	<arg line="-B -Dmaven.repo.local=${ts.home}/.m2/repository"/>
     	 </exec>
         <copy toDir="${deliverable.bundle.dir}/docs/">
         <fileset dir="${ts.home}/user_guides/${deliverable.dir}/target"
                         includes="staging/*.html,staging/css/*,staging/img/*,
                        generated-docs/*.pdf"/>
                </copy>
                <move todir="${deliverable.bundle.dir}/docs/pdf-usersguide">
                    <fileset dir="${deliverable.bundle.dir}/docs/generated-docs"/>
                </move>
                <move todir="${deliverable.bundle.dir}/docs/html-usersguide">
                    <fileset dir="${deliverable.bundle.dir}/docs/staging"/>
                </move>
	</target>

	<target name="create.doc.bundle">
		<delete file="${deliverable.bundle.dir}/../${deliverable.name}tck-doc*.zip"/>
		<zip zipfile="${deliverable.bundle.dir}/../${deliverable.name}tck-doc-${deliverable.version}_${time.stamp.bundle.string}.zip">
                    	<zipfileset dir="${ts.home}/install/${deliverable.dir}/docs"
				includes="**/*.txt, **/*.html, **/*.gif, **/*.css" />
		</zip>
	</target>
   
</project>
