<!--
 -
 - Licensed to the Apache Software Foundation (ASF) under one
 - or more contributor license agreements.  See the NOTICE file
 - distributed with this work for additional information
 - regarding copyright ownership.  The ASF licenses this file
 - to you under the Apache License, Version 2.0 (the
 - "License"); you may not use this file except in compliance
 - with the License.  You may obtain a copy of the License at
 - 
 -   http://www.apache.org/licenses/LICENSE-2.0
 - 
 - Unless required by applicable law or agreed to in writing,
 - software distributed under the License is distributed on an
 - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 - KIND, either express or implied.  See the License for the
 - specific language governing permissions and limitations
 - under the License.
 -
 -->
<project name="QMan - Qpid JMX / WS-DM Adapter" default="build">

    <property name="module.depends" value="client common systests"/>
	<import file="../../module.xml"/>

	<property name="war.name" value="qman.war"/>
    <property name="build.root" value="${module.build}"/>
    <property name="web.module" value="${module.build}/WsdmModule"/>	
    <property name="web-inf.folder" value="${web.module}/WEB-INF"/>
    <property name="classes.folder" value="${web-inf.folder}/classes"/>

	<target name="release-bin-other">
		<mkdir dir="${module.release}${file.separator}log"/>
	</target>
	
	<target name="libs-release" description="copy dependencies into module release">
	    
		<!-- Copy the module dependencies for JMX Bridge release-->
	    <copy todir="${module.release}${file.separator}" failonerror="true" verbose="true">
	    	<fileset dir="${build}" casesensitive="yes" includes="${module.libs}">
	    		<not><filename name="**/*javassist*"/></not>	
	    		<not><filename name="**/*xml-api*"/></not>	    		
	    		<not><filename name="**/*xerces*"/></not>	    		
	    		<not><filename name="**/*xalan*"/></not>	    		
	    		<not><filename name="**/*wsdl*"/></not>	    		
	    		<not><filename name="**/*muse*"/></not>
	    	</fileset>
	    </copy>
		
	    <!-- qpid-management-client.jar : this should be copied only on jmx dist -->
		<copy todir="${module.release}/lib" failonerror="true">
		    <fileset file="${module.jar}"/>
		    <fileset dir="${build.lib}" includes="${module.depends.jars}"/>
		</copy>
		
		<!-- qman.war -->
		<copy todir="${module.release}/lib" failonerror="true">
		    <fileset file="${web.module}${file.separator}${war.name}"/>
		</copy>
	</target>
	
	<target name="prepare-wsdm-module">        
        <mkdir dir="${web.module}"/>
        <mkdir dir="${web-inf.folder}"/>
    	<mkdir dir="${classes.folder}"/>
        <copy file="./web.xml" todir="${web-inf.folder}" verbose="false"/>
		 <copy todir="${classes.folder}" verbose="false">
            <fileset dir="${module.classes}">            	
                <include name="org/apache/qpid/management/servlet/*"/>
                <include name="org/apache/qpid/management/wsdm/**"/>
                <include name="org/apache/qpid/qman/**"/>            	
            	<include name="wsdl/**"/>
            	<include name="muse.xml"/>
            	<include name="router-entries/**"/>
            </fileset>  
        </copy>         
        <copy todir="${web-inf.folder}">
            <fileset dir="${build}" includes="${module.libs}"/>
        </copy>
        <copy todir="${web-inf.folder}/lib">
            <fileset dir="${build}/lib">
                <include name="qpid-client-*.jar"/>
                <include name="qpid-common-*.jar"/>
                <include name="qpid-management-client-*.jar"/>           
            	<exclude name="qpid-client-example*.jar"/>
            	<exclude name="qpid-client-tests*.jar"/>
            	<exclude name="qpid-common-tests*.jar"/>
                <exclude name="qpid-management-client-tests*.jar"/>           
            </fileset>
        </copy>
    </target> 
	  <target name="jar.manifest" depends="compile" if="module.manifest">
	    <jar destfile="${module.jar}" manifest="${module.manifest}">
	    	<fileset dir="${module.classes}" casesensitive="yes">
				<include name="**/**"/>
				<exclude name="org/apache/qpid/management/servlet/*"/>
                <exclude name="org/apache/qpid/management/wsdm/**"/>
	    		<exclude name="org/apache/qpid/qman/**"/>      
            	<exclude name="wsdl/**"/>
            	<exclude name="muse.xml"/>
            	<exclude name="router-entries/**"/>
	    	</fileset>
	    </jar>
	  </target>
	  <target name="jar.nomanifest" depends="compile" unless="module.manifest">
	    <jar destfile="${module.jar}">
	       <metainf dir="${project.root}/resources/" />
	    	<fileset dir="${module.classes}" casesensitive="yes">
				<include name="**/**"/>
				<exclude name="org/apache/qpid/management/servlet/*"/>
                <exclude name="org/apache/qpid/management/wsdm/**"/>
	    		<exclude name="org/apache/qpid/qman/**"/>      
            	<exclude name="wsdl/**"/>
            	<exclude name="muse.xml"/>
            	<exclude name="router-entries/**"/>
	    	</fileset>
	    </jar>
	  </target>
	
    <target name="clean-wsdm-module" description="Clean up web module directory before proceed.">
      <delete dir="${web.module}"/>
    </target>

	<target name="clenaup-wsdm-module-tmp-files" description="Clean up all the temporary files used for build WSDM module.">
      <delete dir="${web-inf.folder}"/>
    </target>

    <target name="create-wsdm-module" description="Creates WSDM Module (Web Application Archive ).">
        <jar destfile="${web.module}/${war.name}" basedir="${web.module}"/>
    </target>
 
    <target name="postbuild" depends="clean-wsdm-module,prepare-wsdm-module,create-wsdm-module,clenaup-wsdm-module-tmp-files" description="Build WS-DM module"/>
</project>