Skip to content

Instantly share code, notes, and snippets.

@nicerobot
Created March 10, 2012 20:17
Show Gist options
  • Save nicerobot/2012944 to your computer and use it in GitHub Desktop.
Save nicerobot/2012944 to your computer and use it in GitHub Desktop.
Easy mvn command. Work-in-progress to improve the crappy mvn interface.
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