From 73f3455dc6ab06f91a97bd4ac0af880feedc9ecb Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 15 Apr 2019 21:28:05 -0700 Subject: [PATCH] Version 1.1 --- preflightcheck.sh | 91 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 19 deletions(-) diff --git a/preflightcheck.sh b/preflightcheck.sh index 630196e..dd16833 100644 --- a/preflightcheck.sh +++ b/preflightcheck.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# Version: 1.0 +# Version: 1.1 # # set source and test locations @@ -22,6 +22,8 @@ sonar="sonarqube" # gradle default command line args opts="--console=plain --no-build-cache --no-daemon" +### + if [ "$java8" = true ] then export JAVA_HOME="$JAVA8_HOME" @@ -36,7 +38,6 @@ date=$(date +%Y) pause() { read -p "Press [Enter] key to continue..." - clear } checkCopyright() { @@ -50,9 +51,11 @@ checkCopyright() { runGradle() { cd "$1" || exit 1 + clear echo -e "> Project: ${cyan}${1}${std} [Gradle]" shift ./gradlew $opts clean $@ || exit 1 + pause cd "$pwd" } @@ -60,15 +63,23 @@ runKobalt() { cd "$1" || exit 1 if [ -f kobalt/src/Build.kt ] then - read -p "Run Kobalt Example? [y/n]: " choice - case $choice in - [Yy] ) - clear - echo -e "> Project: ${cyan}$1${std} [Kobalt]" - shift - ./kobaltw clean $@ ;; - * ) ;; - esac + clear + echo -e "> Project: ${cyan}${1}${std} [Kobalt]" + shift + ./kobaltw clean $@ || exit 1 + pause + fi + cd "$pwd" +} + +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 cd "$pwd" } @@ -83,7 +94,23 @@ checkDeps() { clear echo -e "${cyan}Checking depencencies...${std}" 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() { @@ -93,22 +120,46 @@ gradleCheck() { pause } -examples() { - clear - echo -e "Running examples..." +runExamples() { for ex in "${examples[@]}" do runGradle $ex runKobalt $ex - read -p "Continue? [y/n]: " choice + runMaven $ex + read -p "Continue? [y/n]: " cont clear - case $choice in + case $cont in [Yy] ) continue ;; * ) return ;; esac 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() { clear echo -e "${cyan}Validating copyrights...${std}" @@ -123,11 +174,13 @@ everything() { updateWrappers checkDeps gradleCheck - examples + runExamples validateCopyrights } showMenu() { + clear + echo "${cyan}Preflight Check${std}" echo " 1. Update Wrappers" echo " 2. Check Dependencies" echo " 3. Check Gradle Build" @@ -143,7 +196,7 @@ readOptions(){ 1) updateWrappers ;; 2) checkDeps ;; 3) gradleCheck ;; - 4) examples ;; + 4) examplesMenu ;; 5) validateCopyrights ;; 6) everything ;; *) exit 0 ;;