diff --git a/app/build.gradle b/app/build.gradle index bbc936db2af49c316b8bc8b5c0897d3b09f3f850..885d14cbe773a57646051893bda7456d8905d01f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -26,7 +26,6 @@ android { targetSdkVersion 33 // Android 13 buildConfigField "String", "userAgent", "\"DAVx5\"" - buildConfigField "String", "EMAIL_KEY", "\"${emailKey()}\"" testInstrumentationRunner "at.bitfire.davdroid.CustomTestRunner" @@ -78,12 +77,16 @@ android { buildTypes { debug { + buildConfigField "String", "EMAIL_KEY", "\"invalid\"" } + release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules-release.pro' shrinkResources true + + buildConfigField "String", "EMAIL_KEY", "\"${retrieveEmailKey()}\"" } } @@ -183,12 +186,14 @@ dependencies { testImplementation "com.squareup.okhttp3:mockwebserver:${versions.okhttp}" } -def emailKey() { +def retrieveEmailKey() { Properties properties = new Properties() - try { - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - } catch (ignored) { - // Ignore + properties.load(project.rootProject.file('local.properties').newDataInputStream()) + + String value = properties.getProperty("email.key") + if (value == null) { + throw new GradleException("email.key property not found in local.properties file") } - return properties.getProperty("email.key", "invalid") + + return value }