<!--
 -
 - 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="AMQ Broker" default="build">
    <property name="module.depends" value="management/common common amqp-1-0-common"/>
    <property name="module.test.depends" value="common/tests" />
    <property name="module.main" value="org.apache.qpid.server.Main"/>
    <property name="module.genpom" value="true"/>

    <!-- Add dependencies to the broker pom for the broker-plugins and bdbstore modules -->
    <property name="module.maven.depends" value="broker-plugins/management-http broker-plugins/management-jmx broker-plugins/access-control bdbstore bdbstore/jmx"/>
    <!-- Make them optional -->
    <property name="module.genpom.args" value="-Oqpid-broker-plugins-management-http -Oqpid-broker-plugins-management-jmx -Oqpid-broker-plugins-access-control -Oqpid-bdbstore -Oqpid-bdbstore-jmx"/>

    <import file="../module.xml"/>

    <property name="output.dir" value="${module.precompiled}/org/apache/qpid/server/filter/jms/selector"/>

    <target name="precompile" depends="gen_logging"/>

    <target name="copy-etc-release" if="module.etc.exists" description="copy etc directory if it exists to build tree">
      <copy todir="${module.release}/etc" failonerror="false" flatten="true">
          <fileset dir="${module.etc}" excludes="*.conf,*.jpp"/>
      </copy>
    </target>

    <target name="copy-bin-release" description="copy dependencies into module release">
        <copy todir="${module.release}/bin" failonerror="true">
            <fileset dir="${module.bin}"/>
        </copy>
        <copy todir="${module.release}/bin" failonerror="true" flatten="true">
            <fileset dir="${basedir}/../common/bin"/>
        </copy>
        <chmod dir="${module.release}/bin" perm="ugo+rx" includes="**/*"/>
        <fixcrlf srcdir="${module.release}/bin" fixlast="true" eol="unix"/>
        <fixcrlf srcdir="${module.release}/bin" fixlast="true" eol="dos" includes="*.bat"/>
    </target>

    <target name="release-bin-other" depends="release-bin-other-lib-opt,release-bin-other-bdbstore,release-bin-copy-broker-plugins"/>

    <target name="release-bin-other-lib-opt" depends="release-bin-other-bdbstore" description="make lib/opt dir in the module release">
        <mkdir dir="${module.release}/lib/opt"/>
    </target>

    <target name="release-bin-copy-broker-plugins" description="copy broker-plugins into module release">
        <copy todir="${module.release}/lib/plugins" failonerror="true">
            <fileset dir="${build.scratch.broker.plugins.lib}"/>
        </copy>
    </target>

    <target name="release-bin-other-bdbstore" depends="check-bdbstore-requested" if="bdbstore-requested"
                                         description="copy bdbstore items into module release">
        <copy todir="${module.release}/lib/" failonerror="true">
            <fileset file="${build.lib}/${project.name}-bdbstore-${project.version}.jar"/>
        </copy>
        <copy todir="${module.release}/bin" failonerror="true" flatten="true">
            <fileset dir="${basedir}/../bdbstore/bin"/>
        </copy>
    </target>

    <target name="check-bdbstore-requested">
         <condition property="bdbstore-requested">
             <or>
                 <contains string="${modules.opt}" substring="bdbstore"/>
                 <istrue value="${optional}"/>
             </or>
         </condition>
    </target>

    <target name="release-bin" depends="release-bin-tasks"/>

    <target name="bundle" depends="bundle-tasks"/>
</project>
