Last active
August 29, 2015 14:06
-
-
Save jmatsu/149ca16ddb2f468113e1 to your computer and use it in GitHub Desktop.
Macで開発する人用. 自動Deployまで.
This file contains 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 sh | |
MY_USERNAME='root' # | |
MY_IP_ADDRESS='ip address of server' #Global IP Address | |
UPLOAD_LOCATION_ON_SERVER='/root/' # | |
JAR_WITH_DEPENDENCIES='jar-with-dependencies' | |
function do_deploy () | |
{ | |
local _JAR_FILENAME=`cat pom.xml | egrep 'finalName' | egrep -o '\>.*\<' | sed -e 's/\<//g' -e 's/\>//g' -e 's/\///g' | head -1 | tail -1` | |
if [ "${_JAR_FILENAME}" = "" ]; then | |
local _ARTIFACT_ID=`cat pom.xml | egrep 'artifactId' | egrep -o '\>.*\<' | sed -e 's/\<//g' -e 's/\>//g' -e 's/\///g' | head -1 | tail -1` | |
local _VERSION_OF_ART=`cat pom.xml | egrep 'version' | egrep -o '\>.*\<' | sed -e 's/\<//g' -e 's/\>//g' -e 's/\///g' | head -1 | tail -1` | |
_JAR_FILENAME=$_ARTIFACT_ID'-'$_VERSION_OF_ART'-'$JAR_WITH_DEPENDENCIES'.jar' | |
fi | |
if [ -d target ]; then | |
cd target | |
[ -f $_JAR_FILENAME ] && scp $_JAR_FILENAME $MY_USERNAME@$MY_IP_ADDRESS:$UPLOAD_LOCATION_ON_SERVER | |
else | |
echo 'Failed to deploy.' | |
fi | |
} | |
function clean_all () | |
{ | |
mvn eclipse:clean && mvn clean | |
} | |
function check_mvn () | |
{ | |
if [ ! -x "`which mvn`" ]; then | |
echo 'mvn not found.' | |
exit 1 | |
else | |
echo 'mvn found.' | |
fi | |
} | |
function check_pom () | |
{ | |
if [ ! -f pom.xml ]; then | |
echo 'pom.xml not found.' | |
exit 1 | |
else | |
echo 'pom.xml found.' | |
fi | |
} | |
function main_flow () | |
{ | |
# exportのextensionはpom.xml次第 | |
# BIGCHAのpom.xml記述だとjar | |
echo 'Select number' | |
echo '(1) export jar or etc,' | |
echo '(2) convert to a Eclipse project,' | |
echo '(3) convert to a Eclipse project with m2,' | |
echo '(4) clean only exclude ecilpse files', | |
echo '(5) clean all' | |
local _RESULT_READ_LINE_STDIN='' | |
read -s -n 2 _RESULT_READ_LINE_STDIN </dev/tty | |
echo "Checking ${_RESULT_READ_LINE_STDIN}" | |
case $_RESULT_READ_LINE_STDIN in | |
1) mvn clean && mvn package && do_deploy | |
;; | |
2) clean_all && mvn eclipse:eclipse | |
;; | |
3) clean_all && mvn eclipse:m2eclipse | |
;; | |
4) mvn clean | |
;; | |
5) clean_all | |
;; | |
*) | |
;; | |
esac | |
echo 'Done' | |
} | |
check_mvn && check_pom && main_flow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment