Skip to content

Instantly share code, notes, and snippets.

@omnisis
Created September 7, 2012 01:50
Show Gist options
  • Save omnisis/3662506 to your computer and use it in GitHub Desktop.
Save omnisis/3662506 to your computer and use it in GitHub Desktop.
Maven Bash Function to run archetype generate using "gradle/grails style" GAV descriptors
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256M"
function maven-new-proj() {
if [ ! $# -eq 2 ]; then
echo "Usage: maven-new-proj example.org:some-archetype:1.0 mygroupid.myartifact"
fi
OIFS=$IFS
IFS=':'
read -rA ARCH_GAV <<< "$1"
read -rA PROJ_GAV <<< "$2"
IFS=$OIFS
cmd="mvn archetype:generate -DarchetypeGroupId=${ARCH_GAV[1]} \
-DarchetypeArtifactId=${ARCH_GAV[2]} \
-DarchetypeVersion=${ARCH_GAV[3]} \
-DgroupId=${PROJ_GAV[1]} \
-DartifactId=${PROJ_GAV[2]}"
sh -c "$cmd"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment