#! /bin/bash
[ -d out ] && rm -fr out

ARGS="desktop:run"

function gradlew_do()
{
    echo "./gradlew $ARGS" && ./gradlew $ARGS
}

case "$1" in
    "c")
        shift;
        ARGS="clean assets:build $ARGS"
        gradlew_do
        ;;
    "a")
        shift;
        ARGS="android:installDebug android:run $@"
        gradlew_do
        echo "on failure: sudo adb kill-server; (sudo adb start-server;) sudo adb devices"
        ;;
    "t")
        shift;
        ARGS="core:test $@"
        gradlew_do
        ;;
    "j")
        shift;
        ARGS="core:compileJava $@"
        gradlew_do
        ;;
    "d")
        shift;
        ARGS="desktop:dist $@"
        gradlew_do
        scp ./desktop/build/libs/desktop-1.0.jar erratic:/var/www/public/TankOnTank.jar
        ;;
    "f")
        # java -cp gdx.jar:gdx-natives.jar:gdx-backend-lwjgl.jar:gdx-backend-lwjgl-natives.jar:extensions/gdx-tools/gdx-tools.jar:hiero.jar com.badlogic.gdx.tools.hiero.Hiero
        java -cp ./data/misc/hiero.jar com.badlogic.gdx.tools.hiero.Hiero $@
        exit
        ;;
    *)
        ARGS="$ARGS $@"
        gradlew_do
        ;;
esac