#!/bin/bash

#get java
adoptium_installer || exit 1
install_packages temurin-11-jdk || exit 1

rm -rf ~/jgrasp.zip ~/jgrasp

wget 'https://www.jgrasp.org/dl4g/jgrasp/jgrasp206_10.zip' -O ~/jgrasp.zip || error "Failed to download jgrasp.zip!"
unzip ~/jgrasp.zip || error "Failed to extract jgrasp.zip!"
rm -f ~/jgrasp.zip

echo "Running jgrasp's configure script..."
~/jgrasp/src/configure || error "jgrasp's configure script failed!"

echo "[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=jGRASP
GenericName=IDE
Exec=$HOME/jgrasp/bin/jgrasp %F
Terminal=false
Icon=$(dirname "$0")/icon-64.png
Type=Application
Categories=Application;Development;IDE;
Comment=jGRASP IDE
StartupNotify=true
Keywords=Text;Editor;" > "$([ -e "$HOME/.local/share/applications" ] && echo "$HOME/.local/share/applications" || echo /usr/share/applications)/jgrasp.desktop"

