From 28493bf118fa293037848b0308d78751d2d99a85 Mon Sep 17 00:00:00 2001 From: Ahmad Vazirna Date: Thu, 7 Dec 2023 09:20:27 +0200 Subject: [PATCH] Add gradle task to register service providers --- .gitignore | 3 +- app/build.gradle | 32 +++++++++++++++---- .../org.commcare.util.IEncryptionKeyProvider | 1 - 3 files changed, 27 insertions(+), 9 deletions(-) delete mode 100644 app/src/META-INF/services/org.commcare.util.IEncryptionKeyProvider diff --git a/.gitignore b/.gitignore index 21c6b82b52..63c6ee042e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,5 @@ app/libs/javarosa-libraries.jar build/ **/*~ app/google-services.json -app/fabric.properties \ No newline at end of file +app/fabric.properties +app/src/META-INF/ \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 5e119e9b23..1208a97204 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -161,17 +161,21 @@ ext { HQ_API_PASSWORD = project.properties['HQ_API_PASSWORD'] ?: "" TEST_BUILD_TYPE = project.properties['TEST_BUILD_TYPE'] ?: "debug" FIREBASE_DATABASE_URL = project.properties['FIREBASE_DATABASE_URL'] ?: "" + + // properties related to Service providers + SERVICE_PROVIDERS = ["org.commcare.util.IEncryptionKeyProvider" : "org.commcare.utils.EncryptionKeyProvider"] + SERVICE_PROVIDERS_REL_DIR = "META-INF/services" } afterEvaluate { // Hack to get assets to show up in robolectric tests; try to eventually remove this - preCommcareDebugUnitTestBuild.dependsOn mergeCommcareDebugAssets - processStandaloneDebugGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile - processStandaloneReleaseGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile - processLtsDebugGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile - processLtsReleaseGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile - processCommcareDebugGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile - processCommcareReleaseGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile + preCommcareDebugUnitTestBuild.dependsOn mergeCommcareDebugAssets, registerServiceProviders + processStandaloneDebugGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile, registerServiceProviders + processStandaloneReleaseGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile, registerServiceProviders + processLtsDebugGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile, registerServiceProviders + processLtsReleaseGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile, registerServiceProviders + processCommcareDebugGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile, registerServiceProviders + processCommcareReleaseGoogleServices.dependsOn injectPropertiesIntoFirebaseConfigFile, registerServiceProviders } /** @@ -632,3 +636,17 @@ downloadLicenses { includeProjectDependencies = true dependencyConfiguration = 'compile' } + +task registerServiceProviders { + doLast { + def servProvAbsPath = android.sourceSets.main.java.srcDirs[0].path + File.separator + project.ext.SERVICE_PROVIDERS_REL_DIR + project.ext.SERVICE_PROVIDERS.each { servProv -> + println(servProvAbsPath + File.separator + "$servProv.key") + def file = new File(servProvAbsPath + File.separator + "$servProv.key") + if(!file.getParentFile().exists()) { + file.getParentFile().mkdirs() + } + file.write("$servProv.value") + } + } +} \ No newline at end of file diff --git a/app/src/META-INF/services/org.commcare.util.IEncryptionKeyProvider b/app/src/META-INF/services/org.commcare.util.IEncryptionKeyProvider deleted file mode 100644 index 59ecab0fae..0000000000 --- a/app/src/META-INF/services/org.commcare.util.IEncryptionKeyProvider +++ /dev/null @@ -1 +0,0 @@ -org.commcare.utils.EncryptionKeyProvider