#!/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-4.13-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='
https://download.eclipse.org/releases/2019-09
https://download.eclipse.org/eclipse/updates/4.13
https://www.pydev.org/updates
'
FEATURES='
org.eclipse.jdt.feature.group
org.python.pydev.feature.feature.group
'
eclipse/eclipse \
    -noSplash \
    -application org.eclipse.equinox.p2.director \
    -repository $(echo $REPOS | tr ' ' ,) \
    -i $(echo $FEATURES | tr ' ' ,)

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