Last active
August 29, 2015 14:21
-
-
Save osvein/69aa0395fe5b17ba9ff3 to your computer and use it in GitHub Desktop.
"Mave" Bukkit plugins
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
| #!/usr/bin/env bash | |
| groupId=$(cat src/plugin.yml | grep '^main: .*$' | sed 's/^main: //g' | sed 's/.[^.]*$//g') | |
| name=$(cat src/plugin.yml | grep '^name: .*$' | sed 's/^name: //g') | |
| artifactId=$(echo $name | tr '[:upper:]' '[:lower:]') | |
| version=$(cat src/plugin.yml | grep '^version: .*$' | sed 's/^version: //g') | |
| description="$1" | |
| inceptionYear="$2" | |
| # backup | |
| mkdir bak | |
| cp -r . bak/ | |
| # build directory structure | |
| mkdir src/main | |
| mkdir src/main/java | |
| mkdir src/main/resources | |
| # rearrange files to new directory structure | |
| git mv src/no/ src/main/java/ | |
| git mv src/plugin.yml src/main/resources/ | |
| git mv src/config.yml src/main/resources/ | |
| # create readme | |
| if [ ! -f README.md ]; then | |
| echo "# $name | |
| $description | |
| " > README.md | |
| fi | |
| # create POM | |
| cp ../ExamplePlugin/pom.xml . | |
| sed -i 's@^\t<groupId>.*</groupId>@\t<groupId>'"$groupId"'</groupId>@g' pom.xml | |
| sed -i 's@^\t<name>.*</name>@\t<name>'"$name"'</name>@g' pom.xml | |
| sed -i 's@^\t<artifactId>.*</artifactId>@\t<artifactId>'"$artifactId"'</artifactId>@g' pom.xml | |
| sed -i 's@^\t<version>.*</version>@\t<version>'"$version"'</version>@g' pom.xml | |
| sed -i 's@^\t<url>.*</url>@\t<url>https://github.com/Ano-Tech-Computers/'"$name"'</url>@g' pom.xml | |
| sed -i 's@^\t<description>.*</description>@\t<description>'"$description"'</description>@g' pom.xml | |
| sed -i 's@^\t<inceptionYear>.*</inceptionYear>@\t<inceptionYear>'"$inceptionYear"'</inceptionYear>@g' pom.xml | |
| # delete Eclipse metadata | |
| git rm .classpath | |
| git rm .project | |
| git rm -r .settings/ | |
| rm -r bin/ | |
| # modify gitignore | |
| sed -i 's/^bin\/$/# Maven output/g' .gitignore | |
| sed -i 's/^lib\/$/target/g' .gitignore | |
| echo ' | |
| # Eclipse metadata | |
| .classpath | |
| .project | |
| .settings/ | |
| ' >> .gitignore | |
| git add .gitignore | |
| # modify plugin description | |
| sed -i 's/^name: .*$/name: "${project.name}"/g' src/main/resources/plugin.yml | |
| sed -i 's/^version: .*$/version: "${project.version}"/g' src/main/resources/plugin.yml | |
| sed -i 's/^description: .*$/description: "${project.description}"/g' src/main/resources/plugin.yml | |
| sed -i 's/^website: .*$/website: "${project.url}"/g' src/main/resources/plugin.yml | |
| git add src/main/resources/plugin.yml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment