#!/usr/bin/env bash

set -o errexit
cd

# Use Java 8
JDK_DIR=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.fc29.x86_64
PATH=$JDK_DIR/bin:$PATH

# Eclipse tarball
PLATFORM_TAR=eclipse-platform-I20191020-1800-linux-gtk-x86_64.tar.gz

# Have a fresh clean Eclipse instance
rm -rf eclipse .eclipse workspace
tar xf $PLATFORM_TAR

# Add JDT and Docker tooling
REPOS='
http://download.eclipse.org/eclipse/updates/4.14-I-builds/I20191020-1800
http://download.eclipse.org/releases/2019-12
http://download.eclipse.org/eclipse/updates/4.14
http://download.eclipse.org/datatools/updates/1.14.105-SNAPSHOT/repository
'
FEATURES='
org.eclipse.datatools.enablement.sybase.feature.feature.group
'
eclipse/eclipse \
    -noSplash \
    -application org.eclipse.equinox.p2.director \
    -repository $(echo $REPOS | tr ' ' ,) \
    -i $(echo $FEATURES | tr ' ' ,)

# Run Eclipse
eclipse/eclipse \
    -debug -console -consoleLog
