<?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="europa_drop"    value="R-3.4.1-200809111700"/>
        <property name="dtp_drop"       value="1.6"/>
        <property name="emf_drop"       value="2.4.2/R200902171115"/>
        <property name="gef_drop"       value="R-3.4.1-200809101400"/>
        <property name="wtp_drop"       value="R-3.1-20090616035105"/>

        <property name="base_url"           value="http://www.eclipse.org/downloads/download.php?file="/>
        <property name="europa_win32_url"   value="${base_url}/eclipse/downloads/drops/${europa_drop}/"/>
        <property name="europa_linux_url"   value="${base_url}/eclipse/downloads/drops/${europa_drop}/"/>
        <property name="europa_macos_url"   value="${base_url}/eclipse/downloads/drops/${europa_drop}/"/>
	<property name="testing_url"   value="${base_url}/eclipse/downloads/drops/${europa_drop}/"/>

        <property name="dtp_download_url"   value="${base_url}/datatools/downloads/${dtp_drop}/"/>
        <property name="emf_download_url"   value="${base_url}/modeling/emf/emf/downloads/drops/${emf_drop}/"/>
        <property name="gef_download_url"   value="${base_url}/tools/gef/downloads/drops/${gef_drop}/"/>
        <property name="wtp_download_url"   value="${base_url}/webtools/downloads/drops/R3.1/${wtp_drop}/"/>

        <property name="europa_jee_win32"       value="eclipse-SDK-3.4.1-win32.zip"/>
        <property name="europa_jee_linux"       value="eclipse-SDK-3.4.1-linux-gtk.tar"/>
	<property name="europa_jee_linux_x86_64"       value="eclipse-SDK-3.4.1-linux-gtk-x86_64.tar"/>
        <property name="europa_jee_macos"       value="eclipse-SDK-3.4.1-macosx-carbon.tar"/>
        <property name="europa_jee_linux_gz"    value="${europa_jee_linux}.gz"/>
	<property name="europa_jee_linux_x86_64_gz"    value="${europa_jee_linux_x86_64}.gz"/>
        <property name="europa_jee_macos_gz"    value="${europa_jee_macos}.gz"/>

        <property name="dtp_sdk"    value="dtp-sdk_1.6.2.zip"/>
        <property name="emf_sdo"    value="emf-sdo-xsd-SDK-2.4.2.zip"/>
        <property name="gef_sdk"    value="GEF-ALL-3.4.1.zip"/>
        <property name="wtp_sdk"    value="wtp-sdk-${wtp_drop}.zip"/>
	<property name="testing"    value="eclipse-test-framework-3.4.1.zip"/>

        <property name="protocol"   value="&amp;r=1&amp;protocol=http"/>
    </target>

    <target name="win32" depends="init,common" description="Download Windows-specific artifact(s)">
        <echo>--------------------------------------------------</echo>
        <echo>Downloading ${europa_win32_url}${europa_jee_win32}</echo>
        <echo>--------------------------------------------------</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4"/>
        <get src="${europa_win32_url}${europa_jee_win32}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${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.4/${europa_jee_win32}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="linux" depends="init,common" description="Download Linux-specific artifact(s)">
        <echo>-----------------------------------------------------</echo>
        <echo>Downloading ${europa_linux_url}${europa_jee_linux_gz}</echo>
        <echo>-----------------------------------------------------</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4"/>
        <get src="${europa_linux_url}${europa_jee_linux_gz}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${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.4/${europa_jee_linux_gz}"/>
        <untar  src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${europa_jee_linux}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>
    
    <target name="linux_x86_64" depends="init,common" description="Download x86_64 Linux-specific artifact(s)">
        <echo>-----------------------------------------------------</echo>
        <echo>Downloading ${europa_linux_url}${europa_jee_linux_x86_64_gz}</echo>
        <echo>-----------------------------------------------------</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4"/>
        <get src="${europa_linux_url}${europa_jee_linux_x86_64_gz}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${europa_jee_linux_x86_64_gz}" 
             verbose="true"
             usetimestamp="true"/>
        <echo>Unzipping ${europa_jee_linux_x86_64_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.4/${europa_jee_linux_x86_64_gz}"/>
        <untar  src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${europa_jee_linux_x86_64}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="macos" depends="init,common" description="Download Mac-specific artifact(s)">
        <echo>-----------------------------------------------------</echo>
        <echo>Downloading ${europa_macos_url}${europa_jee_macos_gz}</echo>
        <echo>-----------------------------------------------------</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4"/>
        <get src="${europa_macos_url}${europa_jee_macos_gz}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${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.4/${europa_jee_macos_gz}"/>
        <untar  src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${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"/>
	<antcall target="test-api"/>
    </target>

    <target name="dtp" depends="init" description="Download Data Tools Platform (DTP) artifact">
        <echo>-----------------------------------------</echo>
        <echo>Downloading ${dtp_download_url}${dtp_sdk}</echo>
        <echo>-----------------------------------------</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4"/>
        <get src="${dtp_download_url}${dtp_sdk}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${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.4/${dtp_sdk}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="test-api" depends="init" description="Download Eclipse Test framework">
        <echo>-----------------------------------------</echo>
        <echo>Downloading ${testing_url}${testing}</echo>
        <echo>-----------------------------------------</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4"/>
        <get src="${testing_url}${testing}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${testing}" 
             verbose="true"
             usetimestamp="true"/>
        <echo>Unzipping ${testing} to the expected location in ${LOCAL_M2_REPO}</echo>
        <mkdir dir="${LOCAL_M2_REPO}/eclipse"/>
        <unzip src="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${testing}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    
    <target name="emf" depends="init" description="Download Eclipse Modeling Framework (EMF) artifact">
        <echo>-----------------------------------------</echo>
        <echo>Downloading ${emf_download_url}${emf_sdo}</echo>
        <echo>-----------------------------------------</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4"/>
        <get src="${emf_download_url}${emf_sdo}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${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.4/${emf_sdo}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="gef" depends="init" description="Download Graphical Editing Framework (GEF) artifact">
        <echo>-----------------------------------------</echo>
        <echo>Downloading ${gef_download_url}${gef_sdk}</echo>
        <echo>-----------------------------------------</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4"/>
        <get src="${gef_download_url}${gef_sdk}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${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.4/${gef_sdk}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

    <target name="wtp" depends="init" description="Download Web Tools Platform (WTP) artifact">
        <echo>-----------------------------------------</echo>
        <echo>Downloading ${wtp_download_url}${wtp_sdk}</echo>
        <echo>-----------------------------------------</echo>
        <mkdir dir="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4"/>
        <get src="${wtp_download_url}${wtp_sdk}${protocol}"
             dest="${LOCAL_M2_REPO}/org/eclipse/eclipse/3.4/${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.4/${wtp_sdk}" 
               dest="${LOCAL_M2_REPO}/eclipse"/>
    </target>

</project>
