<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************
 *
 * 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="externals">

    <!-- Each external has 3 properties set, for example for "commons-lang":
         external.commons-lang.internalfilename - the filename when built internally, eg. commons-lang3-3.3.jar
         external.commons-lang.jarclasspath - the path to be placed in the "Class-Path:" entry in JAR files linking to this JAR
         external.commons-lang.path - the full path to the JAR
      -->

    <dirname property="externals.basedir" file="${ant.file.externals}"/>

    <!-- global properties -->
    <property file="${externals.basedir}/../../ant.properties"/>

    <macrodef name="define-external">
        <attribute name="name"/>
        <attribute name="system-test"/>
        <attribute name="system-path"/>
        <attribute name="internal-filename"/>
        <sequential>
            <property name="external.@{name}.internalfilename" value="@{internal-filename}"/>
            <condition property="external.@{name}.jarclasspath" value="@{system-path}" else="${external.@{name}.internalfilename}">
                <equals arg1="@{system-test}" arg2="YES"/>
            </condition>
            <condition property="external.@{name}.path" value="@{system-path}" else="${OUTDIR}/bin/${external.@{name}.internalfilename}">
                <equals arg1="@{system-test}" arg2="YES"/>
            </condition>
        </sequential>
    </macrodef>

    <define-external
        name="commons-codec"
        system-test="${SYSTEM_APACHE_COMMONS}"
        system-path="${COMMONS_CODEC_JAR}"
        internal-filename="commons-codec-1.9.jar"/>

    <define-external
        name="commons-httpclient"
        system-test="${SYSTEM_APACHE_COMMONS}"
        system-path="${COMMONS_HTTPCLIENT_JAR}"
        internal-filename="commons-httpclient-3.1.jar"/>

    <define-external
        name="commons-lang"
        system-test="${SYSTEM_APACHE_COMMONS}"
        system-path="${COMMONS_LANG_JAR}"
        internal-filename="commons-lang3-3.3.jar"/>

    <define-external
        name="commons-logging"
        system-test="${SYSTEM_APACHE_COMMONS}"
        system-path="${COMMONS_LOGGING_JAR}"
        internal-filename="commons-logging-1.1.3.jar"/>

    <define-external
        name="lucene-core"
        system-test="${SYSTEM_LUCENE}"
        system-path="${LUCENE_CORE_JAR}"
        internal-filename="lucene-core-2.9.4-dev.jar"/>

    <define-external
        name="lucene-analyzers"
        system-test="${SYSTEM_LUCENE}"
        system-path="${LUCENE_ANALYZERS_JAR}"
        internal-filename="lucene-analyzers-2.9.4-dev.jar"/>

</project>
