Created
April 6, 2012 02:34
-
-
Save nicerobot/2316218 to your computer and use it in GitHub Desktop.
Template project hierarchy builder for Xcode, eclipse, maven, ...
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
| #!/bin/sh | |
| # curl -ks https://raw.github.com/gist/2316218/nicetempl.sh | sh -s artifact-id group-id | |
| artifactId=${1} | |
| [ "${artifactId}" ] || { | |
| echo "usage: ${0} artifact-id [group-id]" >&2 | |
| exit ${LINENO} | |
| } | |
| groupId=${2:-org.nicerobot} | |
| generate() { | |
| mvn -q archetype:generate \ | |
| -DarchetypeGroupId=org.nicerobot.bump -DarchetypeArtifactId=Bump -DarchetypeVersion=1.0-SNAPSHOT \ | |
| -DgroupId=${1} -DartifactId=${2} -Dversion=1.0-SNAPSHOT <<<"Y" | |
| } | |
| generate "${groupId}" "${artifactId}" || { | |
| git clone git://github.com/nicerobot/bump.git && ( | |
| cd bump && mvn clean install && cd .. && rm -rf bump | |
| ) || exit ${?} | |
| generate "${groupId}" "${artifactId}" || { | |
| exit ${LINENO} | |
| } | |
| } | |
| login="$(sed -n -e '/user/,/name/p' ~/.gitconfig | grep name | awk -F'[ =]+' '{print $2}')" | |
| login=${login:-${USER}} | |
| base=$(cd -P ${artifactId}/projects >/dev/null 2>&1; pwd) || exit ${LINENO} | |
| cd ${base} | |
| find . -name .gitignore | while read g; do ( | |
| cd $(dirname ${g}) | |
| d=${PWD} | |
| n=${d##${base}/} | |
| n=${n//\//.} | |
| name="${groupId}.${artifactId}.${n}" | |
| name="${groupId}.${artifactId}.${n}" | |
| cat >create-repo.sh <<CREATE | |
| #!/bin/sh | |
| token=\$(security find-generic-password -a "${login}" -s 'https://api.github.com' -D 'API Key' -g 2>&1 | grep '^password:' | tr -d '"' | awk >'{print \$2}') | |
| [ "\${token}" ] || { | |
| echo "No github token" >&2 | |
| exit \${LINENO} | |
| } | |
| curl -F "login=${login}" -F "token=\${token}" https://github.com/api/v2/yaml/repos/create -F "name=${name}" && { | |
| git init | |
| touch README | |
| git add -f README .gitignore pom.xml .settings .project .classpath | |
| git commit -m 'first commit' | |
| git remote add origin git@github.com:${login}/${name}.git | |
| git push -u origin master | |
| rm \${0} | |
| } | |
| CREATE | |
| chmod +x create-repo.sh | |
| ); done | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment