statoolinfos/build.sh

88 lines
2 KiB
Bash
Raw Normal View History

2020-09-13 01:28:27 +02:00
#/bin/bash
#
# Display help.
#
function help
{
2024-09-23 00:54:01 +02:00
echo "Build script."
2020-09-13 01:28:27 +02:00
echo "Usage: build.sh [ -h | -help | --help | -snapshot | -local | -full ]"
echo " -h, -help, --help display this help."
echo " -snapshot, --snapshot build a snapshot."
echo " -local, --local build a new version without tag nor version number commit nor Git push."
echo " -tagandpush, --tagandpush build a new version with tag, version number commit and Git push."
echo ""
}
#
2024-08-19 00:54:07 +02:00
# Check env.
2020-09-13 01:28:27 +02:00
#
2024-08-19 00:54:07 +02:00
function check_env
2020-09-13 01:28:27 +02:00
{
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.
2024-09-23 02:12:55 +02:00
JAVA_VERSION=17;
2020-09-13 01:28:27 +02:00
javaVersionCheck=`javac -version 2>&1`
2024-09-23 02:12:55 +02:00
if [[ "$javaVersionCheck" =~ ^.*\ ${JAVA_VERSION}. ]]; then
echo "Java ${JAVA_VERSION} version requirement..... OK"
2020-09-13 01:28:27 +02:00
let "okCount+=1"
else
2024-09-23 02:12:55 +02:00
echo "Java ${JAVA_VERSION} version requirement..... MISSING"
2020-09-13 01:28:27 +02:00
fi
# Git check.
gitCheck=`which git 2>&1`
if [[ "$gitCheck" =~ ^/.* ]]; then
echo "GIT requirement................ OK"
let "okCount+=1"
else
echo "GIT requirement................ MISSING"
fi
if [ "$okCount" == 4 ]; then
echo "Requirement OK"
else
echo "Requirement MISSING, build abort"
2024-08-19 00:54:07 +02:00
exit -1
2020-09-13 01:28:27 +02:00
fi
}
2024-08-19 00:54:07 +02:00
2020-09-13 01:28:27 +02:00
#
# Main.
#
if [ "$#" -eq 0 ] || [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then
help
else
2024-08-19 00:54:07 +02:00
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
2020-09-13 01:28:27 +02:00
fi