@@ -13,12 +13,13 @@ import org.gradle.kotlin.dsl.provideDelegate
13
13
import org.gradle.kotlin.dsl.withType
14
14
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
15
15
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
16
+ import org.jetbrains.kotlin.konan.properties.Properties
16
17
17
18
/* *
18
19
* Configure base Kotlin with Android options
19
20
*/
20
21
internal fun Project.configureKotlinAndroid (
21
- commonExtension : CommonExtension <* , * , * , * , * >,
22
+ commonExtension : CommonExtension <* , * , * , * , * , * >,
22
23
) {
23
24
commonExtension.apply {
24
25
@@ -27,7 +28,13 @@ internal fun Project.configureKotlinAndroid(
27
28
defaultConfig {
28
29
minSdk = 28
29
30
buildFeatures.buildConfig = true
30
- setLocalProperty(project.rootProject)
31
+
32
+ gradleLocalProperties(
33
+ projectRootDir = project.rootProject.projectDir,
34
+ providers = providers
35
+ ).let { properties ->
36
+ setLocalProperties(properties)
37
+ }
31
38
}
32
39
33
40
compileOptions {
@@ -69,7 +76,7 @@ internal fun Project.configureKotlinAndroid(
69
76
}
70
77
}
71
78
72
- private fun CommonExtension <* , * , * , * , * >.kotlinOptions (block : KotlinJvmOptions .() -> Unit ) {
79
+ private fun CommonExtension <* , * , * , * , * , * >.kotlinOptions (block : KotlinJvmOptions .() -> Unit ) {
73
80
(this as ExtensionAware ).extensions.configure(" kotlinOptions" , block)
74
81
}
75
82
@@ -108,12 +115,15 @@ private fun Project.configureKotlin() {
108
115
}
109
116
}
110
117
111
-
112
- fun DefaultConfig.setLocalProperty (
113
- dir : Project
118
+ fun DefaultConfig.setLocalProperties (
119
+ properties : Properties
114
120
) {
115
- val key = gradleLocalProperties(dir.projectDir)[" API_KEY" ]
116
- ?.toString()
117
- ? : throw IllegalStateException (" API_KEY should be initialised" )
118
- buildConfigField(" String" , " API_KEY" , key)
121
+ LocalProperties .values().forEach { property ->
122
+ properties[property.key]
123
+ ?.toString()
124
+ ?.let { value ->
125
+ buildConfigField(property.type, property.buildName, value)
126
+ }
127
+ ? : throw IllegalStateException (" API_KEY should be initialised" )
128
+ }
119
129
}
0 commit comments