Skip to content

Commit 66757a8

Browse files
committed
[CHORE/#210] Convention plugin을 통해 resValue 추가
1 parent 4553b2b commit 66757a8

File tree

4 files changed

+19
-41
lines changed

4 files changed

+19
-41
lines changed

app/build.gradle.kts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import java.util.Properties
2-
31
plugins {
42
id("orbit.android.application")
53
id("orbit.android.compose")
@@ -18,24 +16,8 @@ android {
1816
}
1917

2018
buildTypes {
21-
val localProperties = Properties()
22-
localProperties.load(
23-
project.rootProject.file("local.properties").bufferedReader(),
24-
)
25-
debug {
26-
resValue(
27-
"string",
28-
"admob_app_id",
29-
localProperties["admobAppIdDebug"] as String,
30-
)
31-
}
3219
release {
3320
signingConfig = signingConfigs.getByName("debug")
34-
resValue(
35-
"string",
36-
"admob_app_id",
37-
localProperties["admobAppIdRelease"] as String,
38-
)
3921
}
4022
}
4123
}

build-logic/src/main/java/com/yapp/convention/Extension.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ internal fun CommonExtension<*, *, *, *, *, *>.addBuildConfigFields(project: Pro
4343
}
4444
}
4545

46+
internal fun CommonExtension<*, *, *, *, *, *>.addResValues(project: Project) {
47+
val admobAppIdDebug = project.getLocalProperty("admobAppIdDebug", "")
48+
val admobAppIdRelease = project.getLocalProperty("admobAppIdRelease", "")
49+
val admobAdUnitIdDebug = project.getLocalProperty("admobAdUnitIdDebug", "")
50+
val admobAdUnitIdRelease = project.getLocalProperty("admobAdUnitIdRelease", "")
51+
52+
buildTypes {
53+
getByName("debug") {
54+
resValue("string", "admob_app_id", admobAppIdDebug)
55+
resValue("string", "admob_ad_unit_id", admobAdUnitIdDebug)
56+
}
57+
getByName("release") {
58+
resValue("string", "admob_app_id", admobAppIdRelease)
59+
resValue("string", "admob_ad_unit_id", admobAdUnitIdRelease)
60+
}
61+
}
62+
}
63+
4664
internal fun Project.getLocalProperty(key: String, defaultValue: String? = null): String {
4765
val propertiesFile = rootProject.file("local.properties")
4866
if (propertiesFile.exists()) {

build-logic/src/main/java/com/yapp/convention/KotlinAndroid.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ internal fun Project.configureKotlinAndroid() {
4141
}
4242

4343
addBuildConfigFields(project)
44+
addResValues(project)
4445
}
4546

4647
configureKotlin()

core/ui/build.gradle.kts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import com.yapp.convention.setNamespace
2-
import java.util.Properties
32

43
plugins {
54
id("orbit.android.library")
@@ -8,28 +7,6 @@ plugins {
87

98
android {
109
setNamespace("core.ui")
11-
12-
buildTypes {
13-
val localProperties = Properties()
14-
localProperties.load(
15-
project.rootProject.file("local.properties").bufferedReader(),
16-
)
17-
18-
debug {
19-
resValue(
20-
"string",
21-
"admob_ad_unit_id",
22-
localProperties["admobAdUnitIdDebug"] as String,
23-
)
24-
}
25-
release {
26-
resValue(
27-
"string",
28-
"admob_ad_unit_id",
29-
localProperties["admobAdUnitIdRelease"] as String,
30-
)
31-
}
32-
}
3310
}
3411

3512
dependencies {

0 commit comments

Comments
 (0)