Version 1.1

This commit is contained in:
Erik C. Thauvin 2019-04-15 21:28:05 -07:00
parent 927919b18b
commit 73f3455dc6

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Version: 1.0 # Version: 1.1
# #
# set source and test locations # set source and test locations
@ -22,6 +22,8 @@ sonar="sonarqube"
# gradle default command line args # gradle default command line args
opts="--console=plain --no-build-cache --no-daemon" opts="--console=plain --no-build-cache --no-daemon"
###
if [ "$java8" = true ] if [ "$java8" = true ]
then then
export JAVA_HOME="$JAVA8_HOME" export JAVA_HOME="$JAVA8_HOME"
@ -36,7 +38,6 @@ date=$(date +%Y)
pause() { pause() {
read -p "Press [Enter] key to continue..." read -p "Press [Enter] key to continue..."
clear
} }
checkCopyright() { checkCopyright() {
@ -50,9 +51,11 @@ checkCopyright() {
runGradle() { runGradle() {
cd "$1" || exit 1 cd "$1" || exit 1
clear
echo -e "> Project: ${cyan}${1}${std} [Gradle]" echo -e "> Project: ${cyan}${1}${std} [Gradle]"
shift shift
./gradlew $opts clean $@ || exit 1 ./gradlew $opts clean $@ || exit 1
pause
cd "$pwd" cd "$pwd"
} }
@ -60,15 +63,23 @@ runKobalt() {
cd "$1" || exit 1 cd "$1" || exit 1
if [ -f kobalt/src/Build.kt ] if [ -f kobalt/src/Build.kt ]
then then
read -p "Run Kobalt Example? [y/n]: " choice clear
case $choice in echo -e "> Project: ${cyan}${1}${std} [Kobalt]"
[Yy] ) shift
clear ./kobaltw clean $@ || exit 1
echo -e "> Project: ${cyan}$1${std} [Kobalt]" pause
shift fi
./kobaltw clean $@ ;; cd "$pwd"
* ) ;; }
esac
runMaven() {
cd "$1" || exit 1
if [ -f pom.xml ]
then
clear
echo -e "> Project: ${cyan}${1}${std} [Maven]"
mvn clean compile exec:java || exit 1
pause
fi fi
cd "$pwd" cd "$pwd"
} }
@ -83,7 +94,23 @@ checkDeps() {
clear clear
echo -e "${cyan}Checking depencencies...${std}" echo -e "${cyan}Checking depencencies...${std}"
gradle --console=plain dU || exit 1 gradle --console=plain dU || exit 1
pause read -p "Check Examples depencencies? [y/n] " cont
clear
case $cont in
[Yy] ) for ex in "${examples[@]}"
do
runGradle $(echo "$ex" | cut -d " " -f 1) dU
runKobalt $(echo "$ex" | cut -d " " -f 1) checkVersions
runMaven $(echo "$ex" | cut -d " " -f 1) versions:display-dependency-updates
read -p "Continue? [y/n]: " cont
clear
case $cont in
[Yy] ) continue ;;
* ) return ;;
esac
done ;;
* ) return ;;
esac
} }
gradleCheck() { gradleCheck() {
@ -93,22 +120,46 @@ gradleCheck() {
pause pause
} }
examples() { runExamples() {
clear
echo -e "Running examples..."
for ex in "${examples[@]}" for ex in "${examples[@]}"
do do
runGradle $ex runGradle $ex
runKobalt $ex runKobalt $ex
read -p "Continue? [y/n]: " choice runMaven $ex
read -p "Continue? [y/n]: " cont
clear clear
case $choice in case $cont in
[Yy] ) continue ;; [Yy] ) continue ;;
* ) return ;; * ) return ;;
esac esac
done done
} }
examplesMenu() {
clear
echo -e "${cyan}Examples${std}"
for ex in "${!examples[@]}"
do
printf ' %d. %s\n' $(($ex + 1)) $(echo "${examples[ex]}" | cut -d " " -f 1)
done
echo " $((${#examples[@]} + 1)). Run All Examples"
read -p "Enter choice [1-${#examples[@]}]: " choice
clear
case $choice in
[0-9] ) if [ "$choice" -gt "${#examples[@]}" ]
then
runExamples
examplesMenu
else
runGradle ${examples[$(($choice - 1))]}
runKobalt ${examples[$(($choice - 1))]}
runMaven ${examples[$(($choice - 1))]}
examplesMenu
fi ;;
* ) return ;;
esac
}
validateCopyrights() { validateCopyrights() {
clear clear
echo -e "${cyan}Validating copyrights...${std}" echo -e "${cyan}Validating copyrights...${std}"
@ -123,11 +174,13 @@ everything() {
updateWrappers updateWrappers
checkDeps checkDeps
gradleCheck gradleCheck
examples runExamples
validateCopyrights validateCopyrights
} }
showMenu() { showMenu() {
clear
echo "${cyan}Preflight Check${std}"
echo " 1. Update Wrappers" echo " 1. Update Wrappers"
echo " 2. Check Dependencies" echo " 2. Check Dependencies"
echo " 3. Check Gradle Build" echo " 3. Check Gradle Build"
@ -143,7 +196,7 @@ readOptions(){
1) updateWrappers ;; 1) updateWrappers ;;
2) checkDeps ;; 2) checkDeps ;;
3) gradleCheck ;; 3) gradleCheck ;;
4) examples ;; 4) examplesMenu ;;
5) validateCopyrights ;; 5) validateCopyrights ;;
6) everything ;; 6) everything ;;
*) exit 0 ;; *) exit 0 ;;