Ensure APK build type parameter is valid

Abort build script if the build type parameter value is not valid, instead of assuming the debug build.
This commit is contained in:
Robert Müller 2024-05-11 18:34:42 +02:00
parent e981d48b24
commit d9686591f0

View file

@ -19,6 +19,15 @@ _APK_BASENAME="$1"
_APK_PACKAGE_NAME="$2" _APK_PACKAGE_NAME="$2"
_APK_BUILD_TYPE="$3" _APK_BUILD_TYPE="$3"
if [[ "${_APK_BUILD_TYPE}" == "Debug" ]]; then
_RELEASE_TYPE_NAME=debug
elif [[ "${_APK_BUILD_TYPE}" == "Release" ]]; then
_RELEASE_TYPE_NAME=release
else
printf '\e[31mDid not pass build type to build script: Debug, Release\e[30m\n'
exit 1
fi
_APK_PACKAGE_FOLDER=$(echo "$_APK_PACKAGE_NAME" | sed 's/\./\//g') _APK_PACKAGE_FOLDER=$(echo "$_APK_PACKAGE_NAME" | sed 's/\./\//g')
sed -i "s/DDNet/${_APK_BASENAME}/g" settings.gradle sed -i "s/DDNet/${_APK_BASENAME}/g" settings.gradle
@ -54,15 +63,6 @@ if [[ "${_APK_BUILD_TYPE}" == "Debug" ]]; then
sed -i "s/android.enableR8.fullMode=true/android.enableR8.fullMode=false/g" gradle.properties sed -i "s/android.enableR8.fullMode=true/android.enableR8.fullMode=false/g" gradle.properties
fi fi
_RELEASE_TYPE_NAME=debug
if [[ "${_APK_BUILD_TYPE}" == "Debug" ]]; then
_RELEASE_TYPE_NAME=debug
fi
if [[ "${_APK_BUILD_TYPE}" == "Release" ]]; then
_RELEASE_TYPE_NAME=release
fi
function build_gradle() { function build_gradle() {
java "-Dorg.gradle.appname=Gradle" -classpath gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain --warning-mode all "$1" java "-Dorg.gradle.appname=Gradle" -classpath gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain --warning-mode all "$1"
} }