From 3740992dd151d745aec68e41b9a89746d1a2427e Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Mon, 19 Aug 2024 00:54:07 +0200 Subject: [PATCH] Improved build script. --- build.sh | 114 ++++++++----------------------------------------------- 1 file changed, 16 insertions(+), 98 deletions(-) diff --git a/build.sh b/build.sh index 69a8dab..fafcf3b 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ # function help { - echo "StatoolInfos build script." + echo "Kiss4web build script." echo "Usage: build.sh [ -h | -help | --help | -snapshot | -local | -full ]" echo " -h, -help, --help display this help." echo " -snapshot, --snapshot build a snapshot." @@ -15,93 +15,9 @@ function help } # -# Build snapshot. +# Check env. # -function build_snapshot -{ - okCount=0 - - # Ant check. - antCheck=`which ant` - if [[ "$antCheck" =~ ^/.* ]]; then - echo "Ant requirement................ OK" - let "okCount+=1" - else - echo "Ant requirement................ MISSING" - fi - - # Javac check. - javacCheck=`which javac` - if [[ "$javacCheck" =~ ^/.* ]]; then - echo "Javac requirement.............. OK" - let "okCount+=1" - else - echo "Javac requirement.............. MISSING" - fi - - # Java version check. - javaVersionCheck=`javac -version 2>&1` - if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then - echo "Java 11 version requirement..... OK" - let "okCount+=1" - else - echo "Java 11 version requirement..... MISSING" - fi - - if [ "$okCount" == 3 ]; then - echo "Requirement OK" - ant -f build-snapshot.xml - else - echo "Requirement MISSING, build abort" - fi -} - -# -# Build local. -# -function build_local -{ - okCount=0 - - # Ant check. - antCheck=`which ant` - if [[ "$antCheck" =~ ^/.* ]]; then - echo "Ant requirement................ OK" - let "okCount+=1" - else - echo "Ant requirement................ MISSING" - fi - - # Javac check. - javacCheck=`which javac` - if [[ "$javacCheck" =~ ^/.* ]]; then - echo "Javac requirement.............. OK" - let "okCount+=1" - else - echo "Javac requirement.............. MISSING" - fi - - # Java version check. - javaVersionCheck=`javac -version 2>&1` - if [[ "$javaVersionCheck" =~ ^.*\ 11. ]]; then - echo "Java 11 version requirement..... OK" - let "okCount+=1" - else - echo "Java 11 version requirement..... MISSING" - fi - - if [ "$okCount" == 3 ]; then - echo "Requirement OK" - ant -f build-local.xml - else - echo "Requirement MISSING, build abort" - fi -} - -# -# Build tagandpush. -# -function build_tagandpush +function check_env { okCount=0 @@ -143,26 +59,28 @@ function build_tagandpush if [ "$okCount" == 4 ]; then echo "Requirement OK" - ant -f build-tagandpush.xml else echo "Requirement MISSING, build abort" + exit -1 fi } + # # Main. # if [ "$#" -eq 0 ] || [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then help -elif [ "$1" == "-snapshot" ] || [ "$1" == "--snapshot" ] ; then - build_snapshot -elif [ "$1" == "-local" ] || [ "$1" == "--local" ] ; then - build_local -elif [ "$1" == "-tagandpush" ] || [ "$1" == "--tagandpush" ] ; then - build_tagandpush else - echo "Invalid parameters." - help + check_env + if [ "$1" == "-snapshot" ] || [ "$1" == "--snapshot" ] ; then + ant -f build-snapshot.xml + elif [ "$1" == "-local" ] || [ "$1" == "--local" ] ; then + ant -f build-local.xml + elif [ "$1" == "-tagandpush" ] || [ "$1" == "--tagandpush" ] ; then + ant -f build-tagandpush.xml + else + echo "Invalid parameters." + help + fi fi - -