Skip to content

Instantly share code, notes, and snippets.

@genedelisa
Last active August 29, 2015 14:07
Show Gist options
  • Save genedelisa/e244f73ad6c2d557324e to your computer and use it in GitHub Desktop.
Save genedelisa/e244f73ad6c2d557324e to your computer and use it in GitHub Desktop.
Bash script to generate project from maven archetype for Java EE7 webapp with Arquillian
#!/usr/bin/env bash
# maven archetype helper script
# Gene De Lisa
# === the variables
# your generated output
myartifact=sampleproject
mygroup=com.rockhoppertech
mypackage=com.rockhoppertech
# the archetype we're using
#myrepo=https://nexus.codehaus.org/content/repositories/snapshots/
myrepo=http://repo1.maven.org/
archetypeGroupId=org.javaee-samples
archetypeArtifactId=javaee7-arquillian-archetype
archetypeVersion=1.0.1
# === end variables
usage() { echo "Usage: $0 [-a yourartifactid] [-g yourgroupid] [-p yourpackage]" 1>&2; exit 1; }
while getopts ":a:g:p:" o; do
case "${o}" in
a)
myartifact=${OPTARG}
;;
g)
mygroup=${OPTARG}
;;
p)
mypackage=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${myartifact}" ] || [ -z "${mygroup}" ] || [ -z "${mypackage}" ]; then
usage
fi
echo $myartifact
echo $mygroup
echo $mypackage
mvn -DarchetypeGroupId=$archetypeGroupId -DarchetypeArtifactId=$archetypeArtifactId -DarchetypeVersion=$archetypeVersion -DarchetypeRepository=$myrepo -DgroupId=$mygroup -DartifactId=$myartifact -Dversion=1.0-SNAPSHOT -Dpackage=$mypackage -Darchetype.interactive=false --batch-mode --update-snapshots archetype:generate
@genedelisa
Copy link
Author

Yes, you can type the mvn line in your terminal and it will work. That's a lot of typing with many opportunities to screw up. I know because I've screwed it up so many times that I was motivated to just write this simple script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment