<?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.
  -->

<!-- ================================================================================= -->
<!-- Download Europa Eclipse artifacts and unzip them into the user's local maven repo -->
<!-- ================================================================================= -->
<project name="EuropaArtifacts">

    <target name="init">
        <property name="base_url"               value="http://www.eclipse.org/downloads/download.php?file="/>
        <property name="europa_win32_url"       value="${base_url}/eclipse/downloads/drops/R-3.3-200706251500/"/>
        <property name="europa_linux_url"       value="${base_url}/eclipse/downloads/drops/R-3.3-200706251500/"/>
        <property name="europa_macos_url"       value="${base_url}/eclipse/downloads/drops/R-3.3-200706251500/"/>
        <property name="dtp_download_url"       value="${base_url}/datatools/downloads/1.5/"/>
        <property name="emf_download_url"       value="${base_url}/modeling/emf/emf/downloads/drops/2.3.0/R200706262000/"/>
        <property name="gef_download_url"       value="${base_url}/tools/gef/downloads/drops/R-3.3-200706281000/"/>
        <property name="wtp_download_url"       value="${base_url}/webtools/downloads/drops/R2.0/R-2.0-200706260303/"/>
        <property name="europa_jee_win32"       value="eclipse-SDK-3.3-win32.zip"/>
        <property name="europa_jee_linux"       value="eclipse-SDK-3.3-linux-gtk.tar"/>
        <property name="europa_jee_macos"       value="eclipse-SDK-3.3-macosx-carbon.tar"/>
        <property name="europa_jee_linux_gz"    value="${europa_jee_linux}.gz"/>
        <property name="europa_jee_macos_gz"    value="${europa_jee_macos}.gz"/>
        <property name="dtp_sdk" value="dtp-sdk_1.5.zip"/>
        <property name="emf_sdo" value="emf-sdo-xsd-SDK-2.3.0.zip"/>
        <property name="gef_sdk" value="GEF-SDK-3.3.zip"/>
        <property name="wtp_sdk" value="wtp-sdk-R-2.0-200706260303.zip"/>
        <!-- property name="protocol" value="&amp;r=1&amp;protocol=http"/ -->
        <property name="protocol" value=""/>
    </target>

    <target name="win32" depends="init,common" description="Download Windows-specific artifact(s)">
        <echo>Downloading ${europa_download_url}${europa_jee_win32}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
        <get src="${europa_win32_url}${europa_jee_win32}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_win32}" 
             verbose="true"
             usetimestamp="true"/>
        <echo>Unzipping ${europa_jee_win32} to the expected location in ${LOCAL_M2_REPO}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/eclipse"/>
        <unzip src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_win32}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="linux" depends="init,common" description="Download Linux-specific artifact(s)">
        <echo>Downloading ${europa_download_url}${europa_jee_linux_gz}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
        <get src="${europa_linux_url}${europa_jee_linux_gz}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_linux_gz}" 
             verbose="true"
             usetimestamp="true"/>
        <echo>Unzipping ${europa_jee_linux_gz} to the expected location in ${LOCAL_M2_REPO}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/eclipse"/>
        <gunzip src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_linux_gz}"/>
        <untar  src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_linux}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="macos" depends="init,common" description="Download Mac-specific artifact(s)">
        <echo>Downloading ${europa_download_url}${europa_jee_macos_gz}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
        <get src="${europa_macos_url}${europa_jee_macos_gz}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_macos_gz}" 
             verbose="true"
             usetimestamp="true"/>
        <echo>Unzipping ${europa_jee_macos_gz} to the expected location in ${LOCAL_M2_REPO}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/eclipse"/>
        <gunzip src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_macos_gz}"/>
        <untar  src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${europa_jee_macos}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="common" depends="init" description="Download artifacts common to all OS'es">
        <antcall target="dtp"/>
        <antcall target="emf"/> 
        <antcall target="gef"/> 
        <antcall target="wtp"/> 
    </target>

    <target name="dtp" depends="init" description="Download Data Tools Platform (DTP) artifact">
        <echo>Downloading ${dtp_download_url}${dtp_sdk}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
        <get src="${dtp_download_url}${dtp_sdk}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${dtp_sdk}" 
             verbose="true"
             usetimestamp="true"/>
        <echo>Unzipping ${dtp_sdk} to the expected location in ${LOCAL_M2_REPO}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/eclipse"/>
        <unzip src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${dtp_sdk}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="emf" depends="init" description="Download Eclipse Modeling Framework (EMF) artifact">
        <echo>Downloading ${emf_download_url}${emf_sdo}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
        <get src="${emf_download_url}${emf_sdo}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${emf_sdo}" 
             verbose="true"
             usetimestamp="true"/>
        <echo>Unzipping ${emf_sdo} to the expected location in ${LOCAL_M2_REPO}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/eclipse"/>
        <unzip src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${emf_sdo}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="gef" depends="init" description="Download Graphical Editing Framework (GEF) artifact">
        <echo>Downloading ${gef_download_url}${gef_sdk}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
        <get src="${gef_download_url}${gef_sdk}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${gef_sdk}" 
             verbose="true"
             usetimestamp="true"/>
        <echo>Unzipping ${gef_sdk} to the expected location in ${LOCAL_M2_REPO}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/eclipse"/>
        <unzip src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${gef_sdk}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="wtp" depends="init" description="Download Web Tools Platform (WTP) artifact">
        <echo>Downloading ${wtp_download_url}${wtp_sdk}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3"/>
        <get src="${wtp_download_url}${wtp_sdk}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${wtp_sdk}" 
             verbose="true"
             usetimestamp="true"/>
        <echo>Unzipping ${wtp_sdk} to the expected location in ${LOCAL_M2_REPO}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/eclipse"/>
        <unzip src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.3/${wtp_sdk}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

</project>
