#DEPENDENCIES
#Windows: JDK17, Maven, GitBash, 7zip, choco, GCC, Make
#Linux:   JDK17, Maven, git, bash, unzip, GCC, Make

JRE_URL=""
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
    JRE_URL=""
    echo "Must specify url to pull jre from!"
    exit 1
elif [[ "$OSTYPE" == "msys" ]]; then
    JRE_URL="https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.12%2B7/OpenJDK17U-jre_x64_windows_hotspot_17.0.12_7.zip"
else
    echo "Unsupported operating system!"
    exit 1
fi

#completely clear build directory
rm -rf ./build
#build directory structure
mkdir build
mkdir ./build/assets
#compile project and copy into build dir
mvn clean package
cp ./target/Renderer-0.1.jar ./build/engine.jar
#build launcher
cd ./launcher/
make clean
make build
cd ..
#copy launcher, jdk, and assets into build dir
mv ./launcher/launcher.exe ./build/
curl -L $JRE_URL >> jdk.zip
unzip ./jdk.zip -d ./build/
mv ./build/jdk-* ./build/jdk
rm -f ./jdk.zip
cp -r ./assets/* ./build/assets/