Skip to content

Instantly share code, notes, and snippets.

@maeharin
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maeharin/400a6b86e174b52caea1 to your computer and use it in GitHub Desktop.
Save maeharin/400a6b86e174b52caea1 to your computer and use it in GitHub Desktop.
maven雛形
#!/bin/bash
function exit_with_error() {
echo "[ERROR]"
exit 1
}
#
# parse option
#
while [ $# -gt 0 ]; do
case ${1} in
-a)
ARTIFACT_ID=${2}
shift
;;
-t)
case ${2} in
"quick")
MAVEN_ARCHE_TYPE="maven-archetype-quickstart"
;;
"web")
MAVEN_ARCHE_TYPE="maven-archetype-webapp"
;;
*)
echo "[ERROR] -t must be [quick|web]"
exit 1
;;
esac
shift
;;
*)
echo "[ERROR] invalid option ${1}"
exit 1
;;
esac
shift
done
[ -z "${ARTIFACT_ID}" ] && exit_with_error
[ -z "${MAVEN_ARCHE_TYPE}" ] && exit_with_error
#
# maven
#
mvn archetype:generate \
-DarchetypeArtifactId=${MAVEN_ARCHE_TYPE} \
-DgroupId=com.maeharin \
-DartifactId=${ARTIFACT_ID} \
-Dversion=0.0.1 \
-Dpackage=com.maeharin \
-DinteractiveMode=false
#
# mkdir
#
cd ${ARTIFACT_ID}
mkdir -p src/main/java
mkdir -p src/test/java
mkdir -p src/test/resources
#
# git
#
git init
cat <<EOF > .gitignore
# -----------------------------------------------
# java
# https://github.com/github/gitignore/blob/master/Java.gitignore
# -----------------------------------------------
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# -----------------------------------------------
# eclipse
# https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore
# -----------------------------------------------
*.pydevproject
.metadata
.gradle
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
# Eclipse Core
.project
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# JDT-specific (Eclipse Java Development Tools)
.classpath
# PDT-specific
.buildpath
# sbteclipse plugin
.target
# TeXlipse plugin
.texlipse
# -----------------------------------------------
# maven
# https://github.com/github/gitignore/blob/master/Maven.gitignore
# -----------------------------------------------
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
EOF
echo "================================================="
echo "done!"
echo "read -> http://tomoyamkung.net/2013/07/13/java-maven-project-create/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment