Skip to content

Commit f77ff97

Browse files
refactor: hide BASE_URL
1 parent 1063871 commit f77ff97

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

app/build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.util.Properties
2+
13
plugins {
24
id("kotlin-kapt")
35
alias(libs.plugins.android.application)
@@ -6,6 +8,14 @@ plugins {
68
alias(libs.plugins.serialization)
79
}
810

11+
private val localProperties =
12+
Properties().apply {
13+
val localFile = rootProject.file("local.properties")
14+
if (localFile.exists()) {
15+
load(localFile.inputStream())
16+
}
17+
}
18+
919
android {
1020
namespace = "woowacourse.shopping"
1121
compileSdk = 35
@@ -25,6 +35,7 @@ android {
2535
buildTypes {
2636
debug {
2737
buildConfigField("boolean", "DEBUG", "true")
38+
buildConfigField("String", "BASE_URL", localProperties["base.url"].toString())
2839
}
2940
release {
3041
isMinifyEnabled = false
@@ -33,6 +44,7 @@ android {
3344
"proguard-rules.pro",
3445
)
3546
buildConfigField("boolean", "DEBUG", "false")
47+
buildConfigField("String", "BASE_URL", localProperties["base.url"].toString())
3648
}
3749
}
3850
compileOptions {

app/src/main/java/woowacourse/shopping/data/API.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object API {
2020
private val retrofit =
2121
Retrofit
2222
.Builder()
23-
.baseUrl("http://techcourse-lv2-alb-974870821.ap-northeast-2.elb.amazonaws.com")
23+
.baseUrl(BuildConfig.BASE_URL)
2424
.client(client)
2525
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
2626
.build()

app/src/main/java/woowacourse/shopping/data/ProductsHttpClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import woowacourse.shopping.data.product.dto.ProductsResponse
1717
import java.util.Base64
1818

1919
class ProductsHttpClient(
20-
private val baseUrl: String = "http://techcourse-lv2-alb-974870821.ap-northeast-2.elb.amazonaws.com",
20+
private val baseUrl: String = BuildConfig.BASE_URL,
2121
) {
2222
fun getCart(
2323
page: Int,

0 commit comments

Comments
 (0)