<?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.
  -->

<!--
 |
 | Ant script to start Eclipse via the Equinox launcher
 |
 |
 | @version $Rev$ $Date$
 |
 -->
<project name="GEP Automated Testsuite Launcher" >

    <condition property="is64bitJDK" >
        <!--We only check JVM bit model here.  It works fine even 32-bit JVM is used on 64-bit OS -->
        <equals arg1="${sun.arch.data.model}" arg2="64" />
    </condition>

    <condition property="arch" value="x86_64" >
        <isset property="is64bitJDK" />
    </condition>

    <condition property="arch" value="x86" >
        <not>
            <isset property="is64bitJDK" />
        </not>
    </condition>

    <!--
     |
     | Copy and rename the eqiunox launcher jar,
     | Copy and rename the org.eclipse.test folder
     |
     -->
    <target name="init">
        <!-- Prompt to install aries tools manually -->
        <input>
Please install Aries tools manually for eclipse under testsuite/launcher/eclipse,

Free Aries tools download URL is http://www.ibm.com/developerworks/rational/downloads/10/rationaldevtoolsforosgiapplications.html

Press Enter to continue...
        </input>

        <property name="eclipse-home" value="eclipse"/>
        <copy tofile="${eclipse-home}/eclipse/plugins/org.eclipse.equinox.launcher.jar">
            <fileset dir="${eclipse-home}/eclipse/plugins"
              includes="**/org.eclipse.equinox.launcher_*.jar"/>
        </copy>
        <mkdir dir="${eclipse-home}/eclipse/plugins/org.eclipse.test"/>
        <copy todir="${eclipse-home}/eclipse/plugins/org.eclipse.test">
            <fileset dir="${eclipse-home}/eclipse/plugins/org.eclipse.test_3.3.0"/>
        </copy>
    </target>

    <!--
     |
     | Start Eclipse via the Equinox launcher
     |
     -->
    <macrodef name="launch" description="Start Equinox launcher" >
        <attribute name="os" />
        <attribute name="ws" />
        <sequential>
            <echo message="Launching Equinox with -Dos=@{os} -Dws=@{ws} -Darch=${arch}" />
            <java classname="org.eclipse.equinox.launcher.Main"
                  failonerror="true"
                  fork="true">
                <classpath>
                    <pathelement path="${eclipse-home}/eclipse/plugins/org.eclipse.equinox.launcher.jar"/>
                </classpath>
                <arg line="-data workspace" />
                <arg line="-application org.eclipse.ant.core.antRunner"/>
                <arg line="-file testsuite.xml"/>
                <arg value="all"/>
                <arg value="-Dos=@{os}"/>
                <arg value="-Dws=@{ws}"/>
                <arg value="-Darch=${arch}"/>
            </java>
        </sequential>
    </macrodef>

    <target name="mac" depends="init" description="Start Equinox launcher on mac" >
        <launch os="macosx" ws="cocoa" />
    </target>

    <target name="unix" depends="init" description="Start Equinox launcher on unix" >
        <launch os="linux" ws="gtk" />
    </target>

    <target name="windows" depends="init" description="Start Equinox launcher on windows" >
        <launch os="win32" ws="win32" />
    </target>

</project>
