#!/usr/bin/env bash

case $1 in
exec)
    echo "mvn -Dexec.executable='echo' -Dexec.args='{project.artifactId}' exec:exec -q"
    mvn -Dexec.executable='echo' -Dexec.args=$1' ${project.artifactId}' exec:exec -q
    ;;
checkstyle)
    echo "mvn checkstyle:checkstyle > check.log"
    mvn checkstyle:checkstyle > check.log
    ;;
dependency)
    echo "mvn dependency:tree > dep.log"
    mvn dependency:tree > dep.log
    ;;
docker)
    echo "mvn clean package -Dmaven.test.skip=true -Pdocker"
    mvn clean package -Dmaven.test.skip=true
    ;;
test)
    echo "mvn clean package -Ptest"
    java -version
    mvn clean package -Dmaven.test.skip=true
    ;;
sonarqube)
    echo "mvn clean package && sonar-scanner"
    export JAVA_HOME=$JAVA_11_HOME
    export PATH="$JAVA_11_HOME/bin:$PATH"
    java -version
    if [ $# -eq 6 ]; then
        mvn clean package -Dmaven.test.skip=true -Dmaven.compiler.source=11 -Dmaven.compiler.target=11 \
        $3 $4 $5 $6 \
        -Dsonar.login="admin" -Dsonar.password="admin1@3"
    fi
    ;;
*)
    echo "mvn clean package -Dmaven.test.skip=true -Prelease"
    java -version
    mvn clean package -Dmaven.test.skip=true
    ;;
esac