Created
March 10, 2012 20:17
-
-
Save nicerobot/2012944 to your computer and use it in GitHub Desktop.
Easy mvn command. Work-in-progress to improve the crappy mvn interface.
This file contains hidden or 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
mvn() { | |
# usage: mvn phase... -- [groupId [artifcatId [archetypeArtifactId]]] [-Dname=value]... | |
local mvn=$(which mvn) || return 1 | |
[ ${mvn:0:1} = '/' ] || return 2 | |
local phases=() | |
local rest=() | |
local order=(groupId artifactId archetypeArtifactId) | |
local n=-1 | |
local m=${#order[@]} | |
local add=phases | |
for p in "${@}"; do | |
[ '--' == ${p} ] && { | |
add=rest | |
n=0 | |
continue | |
} | |
if ((n>=0 && n<m)); then | |
if [ ${p:0:2} != '-D' ]; then | |
eval "local ${order[n]}='-D${order[n]}=${p}'" | |
((n++)) | |
else | |
rest=(${rest[@]} ${p}) | |
fi | |
else | |
eval ${add}'=(${'${add}'[@]} '${p}')' | |
fi | |
done | |
${mvn} ${phases[@]} ${groupId} ${artifactId} ${archetypeArtifactId} ${rest[@]} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment