Skip to content

Commit f73073f

Browse files
authored
Merge pull request #1913 from liutikas/removesecretsplugin
Move to a custom setup for BuildConfig.BACKEND_URL
2 parents fffa526 + abac757 commit f73073f

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

core/network/build.gradle.kts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17+
import com.android.build.api.variant.BuildConfigField
18+
import java.io.StringReader
19+
import java.util.Properties
20+
1721
plugins {
1822
alias(libs.plugins.nowinandroid.android.library)
1923
alias(libs.plugins.nowinandroid.android.library.jacoco)
2024
alias(libs.plugins.nowinandroid.hilt)
2125
id("kotlinx-serialization")
22-
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
2326
}
2427

2528
android {
@@ -34,10 +37,6 @@ android {
3437
}
3538
}
3639

37-
secrets {
38-
defaultPropertiesFileName = "secrets.defaults.properties"
39-
}
40-
4140
dependencies {
4241
api(libs.kotlinx.datetime)
4342
api(projects.core.common)
@@ -52,3 +51,22 @@ dependencies {
5251

5352
testImplementation(libs.kotlinx.coroutines.test)
5453
}
54+
55+
val backendUrl = providers.fileContents(
56+
isolated.rootProject.projectDirectory.file("local.properties")
57+
).asText.map { text ->
58+
val properties = Properties()
59+
properties.load(StringReader(text))
60+
if (properties.containsKey("BACKEND_URL"))
61+
(properties["BACKEND_URL"] as String)
62+
else "http://example.com"
63+
// Move to returning `properties["BACKEND_URL"] as String?` after upgrading to Gradle 9.0.0
64+
}.orElse("http://example.com")
65+
66+
androidComponents {
67+
onVariants {
68+
it.buildConfigFields.put("BACKEND_URL", backendUrl.map { value ->
69+
BuildConfigField(type = "String", value = """"$value"""", comment = null)
70+
})
71+
}
72+
}

secrets.defaults.properties

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)