From e981d48b2424a9f23be5d3e33201b25561d7d5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sat, 11 May 2024 18:29:46 +0200 Subject: [PATCH] Extract `build_gradle` function, fix Gradle use without arguments Extract `build_gradle` function to reduce duplicate code for running the Gradle build. Remove the initial invocation of Gradle without a build target, which has no effect and was causing an error message during the build. --- scripts/android/files/build.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/android/files/build.sh b/scripts/android/files/build.sh index 18ef70cce..ada181377 100644 --- a/scripts/android/files/build.sh +++ b/scripts/android/files/build.sh @@ -63,19 +63,20 @@ if [[ "${_APK_BUILD_TYPE}" == "Release" ]]; then _RELEASE_TYPE_NAME=release fi -APP_BASE_NAME=Gradle -CLASSPATH=gradle-wrapper.jar -java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all +function build_gradle() { + java "-Dorg.gradle.appname=Gradle" -classpath gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain --warning-mode all "$1" +} + if [[ "${_APK_BUILD_TYPE}" == "Debug" ]]; then - java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all builddebug - java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all assembleDebug + build_gradle builddebug + build_gradle assembleDebug else - java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all buildrelease - java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all assembleRelease + build_gradle buildrelease + build_gradle assembleRelease fi cp build/outputs/apk/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME".apk "$_APK_BASENAME".apk if [[ "${_APK_BUILD_TYPE}" == "Release" ]]; then - java "-Dorg.gradle.appname=${APP_BASE_NAME}" -classpath "${CLASSPATH}" org.gradle.wrapper.GradleWrapperMain --warning-mode all bundleRelease + build_gradle bundleRelease cp build/outputs/bundle/"$_RELEASE_TYPE_NAME"/"$_APK_BASENAME"-"$_RELEASE_TYPE_NAME".aab "$_APK_BASENAME".aab fi