echo off
echo [INFO] Use maven jetty-plugin run the project, with debug options.

CWD=`pwd`
cd $CWD
cd ..

mvn compile -e -o

echo --------------------- Set Jrebel ---------------------
export REBEL_HOME=./bin
export REBEL_CLASS_PATH=./target/classes
export REBEL_RESOURCES_PATH=./src/main/webapp
export MAVEN_OPTS="$MAVEN_OPTS -javaagent:$REBEL_HOME/jrebel.jar -noverify -Drebel.spring_plugin=true -Drebel.hibernate_plugin=true"
export MAVEN_OPTS="$MAVEN_OPTS -Drebel.dirs=$REBEL_CLASS_PATH"
echo ${MAVEN_OPTS}

echo --------------------- Set Jmxremote ---------------------
export JMX_OPTS=
export JMX_OPTS="$JMX_OPTS -Dcom.sun.management.jmxremote=true"
export JMX_OPTS="$JMX_OPTS -Dcom.sun.management.jmxremote.port=9090"
export JMX_OPTS="$JMX_OPTS -Dcom.sun.management.jmxremote.ssl=false"
export JMX_OPTS="$JMX_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
echo ${JMX_OPTS}

echo --------------------- Set Maven Debug ---------------------
export MAVEN_OPTS="$JMX_OPTS $MAVEN_OPTS -XX:MaxPermSize=128m  -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
#export MAVEN_OPTS="$MAVEN_OPTS -XX:MaxPermSize=128m  -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"
echo ${MAVEN_OPTS}

echo --------------------- RUN ---------------------
mvn -Djetty.port=9091 jetty:run -Dmaven.test.skip=true -e -o
