Created
February 8, 2011 03:40
-
-
Save joakime/815809 to your computer and use it in GitHub Desktop.
Bash Functions for Maven Development.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
droppath() | |
{ | |
PATTERN="$1" | |
PATH=$(echo $PATH | \ | |
sed -e "s;:?[^:]*$PATTERN[^:]*;;g" \ | |
-e "s;[^:]*$PATTERN[^:]*:\?;;g" \ | |
-e "s;::;:;g") | |
} | |
usemaven() | |
{ | |
MVN="$@" | |
if [ ! -d "$MVN" ] ; then | |
echo "ERROR: Invalid maven directory: $MVN" 1>&2 | |
else | |
droppath maven | |
M2_HOME="$MVN" | |
MVNCMD="$MVN/bin/mvn" | |
case "`uname`" in | |
CYGWIN*) M2_HOME=`cygpath --windows --absolute $MVN` | |
MVNCMD=`cygpath --unix --absolute $MVN/bin/mvn` | |
;; | |
esac | |
PATH=$MVN/bin:$PATH | |
export M2_HOME | |
export PATH | |
echo "M2_HOME is now $M2_HOME" | |
mvn --version | |
fi | |
} | |
usejdk() | |
{ | |
JDK="$@" | |
if [ ! -d "$JDK" ] ; then | |
echo "ERROR: Invalid jdk directory: $JDK" 1>&2 | |
else | |
droppath jdk | |
droppath jre | |
JAVA_HOME="$JDK" | |
case "`uname`" in | |
CYGWIN*) JAVA_HOME=`cygpath --windows --absolute $JDK` | |
;; | |
esac | |
PATH=$JDK/bin:$PATH | |
export JAVA_HOME | |
export PATH | |
java -version | |
fi | |
} | |
function debugOn() | |
{ | |
export MAVEN_OPTS="$MAVEN_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005" | |
} | |
function debugOff() | |
{ | |
export MAVEN_OPTS="-Xmx512m" | |
} | |
function debugMemory() | |
{ | |
export MAVEN_OPTS="-Xmx512m -agentlib:yjpagent=alloc,usedmem=80,disablecounts -XX:+HeapDumpOnOutOfMemoryError" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment