#!/bin/sh
#  Copyright (c) 2003-2006 by nexB, Inc. http://www.nexb.com/ - All rights reserved.
#  This software is licensed under the terms of the Open Software License version 2.1.
#  A copy of the license is available at http://opensource.org/licenses/osl-2.1.php

# Usage: Use anteclipse like you would use Ant from the command line.
# See http://ant.apache.org/manual/running.html for more details 
# You must define environment variables:
# JAVA_HOME: pointing to your JDK installation
# ECLIPSE_HOME: pointing to your Eclipse installation

# Customize those values based on your local machine capacity
JAVA_OPTS="-Xms768M -Xmx1024M"

OS=`uname`
# Setting the windowing system and providing a workspace help avoiding problems
if [ $OS == 'Darwin' ]; then
  	ECLIPSE_OPTS="-ws carbon -data /tmp/ws"
elif [ $OS == 'Linux' ]; then
    # TODO: verify right options for Linux
  	ECLIPSE_OPTS="-data /tmp/ws"
else
    echo Operating System not supported: $OS
    exit
fi

if ! [ -d "$ECLIPSE_HOME" ]; then
    echo No ECLIPSE_HOME environment variable defined.
    exit
fi

if ! [ -d "$JAVA_HOME" ]; then
    echo No JAVA_HOME environment variable defined.
    exit
fi

$JAVA_HOME/bin/java $JAVA_OPTS -cp "$ECLIPSE_HOME/startup.jar" org.eclipse.core.launcher.Main $ECLIPSE_OPTS -application org.eclipse.ant.core.antRunner "$@"