From c99b42068f995d1be35a2bf05e848ec0e323fb3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EC=A7=84?= Date: Tue, 20 Aug 2024 02:07:56 +0900 Subject: [PATCH] [Chore] migrate build.gradle.kts & lib.version.toml (#194) * chore: migrate build.gradle.kts & lib.version.toml * chore: toml use kebab-case --- app/build.gradle | 133 ---------------- app/build.gradle.kts | 150 ++++++++++++++++++ app/proguard-rules.pro | 2 +- .../com/eatssu/android/di/NetworkModule.kt | 3 +- .../com/eatssu/android/util/RetrofitImpl.kt | 2 +- build.gradle | 9 -- build.gradle.kts | 9 ++ gradle.properties | 1 - gradle/libs.versions.toml | 94 +++++++++++ 9 files changed, 256 insertions(+), 147 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 gradle/libs.versions.toml diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 0eee6f00..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,133 +0,0 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' - id 'kotlin-parcelize' - id 'com.google.gms.google-services' - id 'com.google.firebase.crashlytics' - id 'kotlin-android' - id 'kotlin-kapt' - id 'dagger.hilt.android.plugin' -} - - Properties properties = new Properties() - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - - -android { - namespace 'com.eatssu.android' - compileSdk 34 - - defaultConfig { - applicationId "com.eatssu.android" - minSdk 23 - targetSdk 34 - versionCode 16 - versionName "1.1.14" - - - buildConfigField("String", "KAKAO_NATIVE_APP_KEY", "\"${properties.get('KAKAO_NATIVE_APP_KEY')}\"") - manifestPlaceholders = [KAKAO_NATIVE_APP_KEY: properties.get('KAKAO_NATIVE_APP_KEY')] - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildFeatures { - buildConfig = true - viewBinding = true - dataBinding = true - } - - buildTypes { - debug { - buildConfigField("String", "BASE_URL", properties["DEV_BASE_URL"]) - } - release { - buildConfigField("String", "BASE_URL", properties["PROD_BASE_URL"]) - - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = '17' - } - splits { - abi { - enable true - reset() - universalApk true - } - } - lint{ - abortOnError = false - } -} - -dependencies { - - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'com.google.android.material:material:1.8.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'com.jakewharton.threetenabp:threetenabp:1.4.4' - implementation 'com.prolificinteractive:material-calendarview:1.4.3' - implementation 'androidx.recyclerview:recyclerview:1.3.2' - implementation 'com.google.android.datatransport:transport-runtime:3.1.2' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation 'androidx.activity:activity-ktx:1.8.2' - implementation 'androidx.fragment:fragment-ktx:1.6.2' - annotationProcessor 'com.android.databinding:compiler:3.1.4' - - //retrofit2 - 서버통신 - implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.retrofit2:converter-gson:2.9.0' - implementation 'com.google.code.gson:gson:2.10.1' // Gson - - //OkHttp: 통신 로그 확인하기 위함 - implementation 'com.squareup.okhttp3:okhttp:4.12.0' //포스팅 당시 4.9.0 버전 기준 - implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' - - //glide - 사진 업로드 - implementation 'com.github.bumptech.glide:glide:4.15.1' - annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' - - //이미지 압축 - implementation 'id.zelory:compressor:3.0.1' - - //coroutines - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3' - implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.7.0" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3' - - // 카카오 로그인 모듈 - implementation "com.kakao.sdk:v2-user:2.8.6" // 카카오 로그인 - - //hilt - implementation 'com.google.dagger:hilt-android:2.50' - kapt "com.google.dagger:hilt-android-compiler:2.50" - annotationProcessor 'com.google.dagger:hilt-compiler:2.50' - - // viewmodel과 livedata - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0" - implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.7.0" - - //firebase - implementation 'com.google.android.gms:play-services-base:18.0.1' - implementation 'com.google.firebase:firebase-config-ktx:21.4.1' - implementation platform('com.google.firebase:firebase-bom:32.2.2') - implementation 'com.google.firebase:firebase-analytics-ktx' - implementation 'com.google.firebase:firebase-crashlytics' - - //Timer - implementation "com.jakewharton.timber:timber:5.0.1" -} - -kapt { - correctErrorTypes true -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..366a54af --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,150 @@ +import java.util.Properties + +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id("kotlin-parcelize") + id("com.google.gms.google-services") + id("com.google.firebase.crashlytics") + id("kotlin-android") + id("kotlin-kapt") + id("dagger.hilt.android.plugin") +} + +android { + namespace = "com.eatssu.android" + compileSdk = 34 + + defaultConfig { + applicationId = "com.eatssu.android" + minSdk = 23 + targetSdk = 34 + versionCode = 17 + versionName = "1.1.14" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildFeatures { + buildConfig = true + viewBinding = true + dataBinding = true + } + + buildTypes { + release { + val p = Properties() + p.load(project.rootProject.file("local.properties").reader()) + + val baseUrl: String = p.getProperty("PROD_BASE_URL") + buildConfigField("String", "BASE_URL", baseUrl) + + val kakaoKey: String = p.getProperty("KAKAO_NATIVE_APP_KEY") + buildConfigField("String", "KAKAO_NATIVE_APP_KEY", "\"$kakaoKey\"") + manifestPlaceholders["KAKAO_NATIVE_APP_KEY"] = kakaoKey + + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + + } + + debug { + val p = Properties() + p.load(project.rootProject.file("local.properties").reader()) + + val baseUrl: String = p.getProperty("DEV_BASE_URL") + buildConfigField("String", "BASE_URL", baseUrl) + + val kakaoKey: String = p.getProperty("KAKAO_NATIVE_APP_KEY") + buildConfigField("String", "KAKAO_NATIVE_APP_KEY", "\"$kakaoKey\"") + manifestPlaceholders["KAKAO_NATIVE_APP_KEY"] = kakaoKey + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = "17" + } + + splits { + abi { + isEnable = true + reset() + isUniversalApk = true + } + } + + lint { + abortOnError = false + } +} + +dependencies { + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.material) + implementation(libs.constraintlayout) + implementation(libs.threetenabp) + implementation(libs.material.calendarview) + implementation(libs.recyclerview) + implementation(libs.transport.runtime) + implementation(libs.activity) + implementation(libs.fragment) + + // Testing libraries + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.espresso.core) + + //retrofit2: 서버통신 + implementation(libs.retrofit) + implementation(libs.converter.gson) + + // Gson for JSON parsing + implementation(libs.gson) + + //OkHttp: 통신 로그 확인하기 위함 + implementation(libs.okhttp) + implementation(libs.okhttp.logging.interceptor) + + //glide: 사진 업로드 + implementation(libs.glide) + kapt(libs.glide.compiler) + + //compressor: 이미지 압축 + implementation(libs.compressor) + + // Coroutines for concurrency + implementation(libs.coroutines) + implementation(libs.coroutines.core) + implementation(libs.lifecycle.runtime) + + // Kakao login SDK + implementation(libs.kakao.login) + + // Hilt for Dependency Injection + implementation(libs.hilt) + kapt(libs.hilt.compiler) + + // ViewModel and LiveData + implementation(libs.lifecycle.viewmodel) + implementation(libs.lifecycle.livedata) + + // Firebase + implementation(libs.play.services.base) + implementation(libs.firebase.config) + implementation(platform(libs.firebase.bom)) + implementation(libs.firebase.analytics) + implementation(libs.firebase.crashlytics) + + + // Timber for logging + implementation(libs.timber) +} + +kapt { + correctErrorTypes = true +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index b1da94d2..e9a2e346 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/app/src/main/java/com/eatssu/android/di/NetworkModule.kt b/app/src/main/java/com/eatssu/android/di/NetworkModule.kt index 77641470..6bf6bf6b 100644 --- a/app/src/main/java/com/eatssu/android/di/NetworkModule.kt +++ b/app/src/main/java/com/eatssu/android/di/NetworkModule.kt @@ -2,6 +2,7 @@ package com.eatssu.android.di import com.eatssu.android.BuildConfig +import com.eatssu.android.BuildConfig.BASE_URL import com.eatssu.android.data.service.InquiryService import com.eatssu.android.data.service.OauthService import com.eatssu.android.data.service.UserService @@ -35,8 +36,6 @@ class NullOnEmptyConverterFactory : Converter.Factory() { @InstallIn(SingletonComponent::class) object NetworkModule { - private const val BASE_URL = BuildConfig.BASE_URL - @Singleton @Provides fun provideOkHttpClient( diff --git a/app/src/main/java/com/eatssu/android/util/RetrofitImpl.kt b/app/src/main/java/com/eatssu/android/util/RetrofitImpl.kt index e93af784..c010dd80 100644 --- a/app/src/main/java/com/eatssu/android/util/RetrofitImpl.kt +++ b/app/src/main/java/com/eatssu/android/util/RetrofitImpl.kt @@ -9,6 +9,7 @@ import android.util.Log import android.widget.Toast import com.eatssu.android.App import com.eatssu.android.BuildConfig +import com.eatssu.android.BuildConfig.BASE_URL import com.eatssu.android.base.BaseResponse import com.eatssu.android.data.dto.response.TokenResponse import com.eatssu.android.di.network.TokenInterceptor @@ -25,7 +26,6 @@ import java.io.IOException import java.lang.reflect.Type object RetrofitImpl { - private const val BASE_URL = BuildConfig.BASE_URL val size = 10 * 1024 * 1024 // 10MB Cache size diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 4c23328a..00000000 --- a/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - id 'com.android.application' version '8.2.2' apply false - id 'com.android.library' version '8.2.2' apply false - id 'org.jetbrains.kotlin.android' version '1.8.10' apply false - id 'com.google.gms.google-services' version "4.3.15" apply false - id 'com.google.firebase.crashlytics' version "2.9.9" apply false - id 'com.google.dagger.hilt.android' version '2.50' apply false -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..e74bee41 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,9 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.google.services) apply false + alias(libs.plugins.firebase.crashlytics) apply false + alias(libs.plugins.hilt.android) apply false +} diff --git a/gradle.properties b/gradle.properties index bb36cd24..d026a989 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,5 +22,4 @@ kotlin.code.style=official # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true android.enableJetifier=true -android.defaults.buildfeatures.buildconfig=true android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..92722d7e --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,94 @@ +[versions] +android = "8.2.2" +androidx-core = "1.7.0" +androidx-appcompat = "1.6.1" +material = "1.8.0" +constraintlayout = "2.1.4" +threetenabp = "1.4.4" +material-calendarview = "1.4.3" +recyclerview = "1.3.2" +transport-runtime = "3.1.2" +junit = "4.13.2" +androidx-test-ext-junit = "1.1.5" +espresso-core = "3.5.1" +activity = "1.8.2" +fragment = "1.6.2" +databinding-compiler = "3.1.4" +retrofit = "2.9.0" +converter-gson = "2.9.0" +gson = "2.10.1" +okhttp = "4.12.0" +glide = "4.15.1" +glide-compiler = "4.12.0" +compressor = "3.0.1" +coroutines = "1.7.3" +lifecycle-runtime = "2.7.0" +lifecycle-viewmodel = "2.7.0" +lifecycle-livedata = "2.7.0" +kakao-login = "2.8.6" +hilt = "2.50" +play-services-base = "18.0.1" +firebase-config = "21.4.1" +firebase-bom = "32.2.2" +firebase-crashlytics = "2.9.9" +timber = "5.0.1" +google-services = "4.4.2" +kotlin-android = "1.8.10" + + +[libraries] +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core" } +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" } +material = { group = "com.google.android.material", name = "material", version.ref = "material" } +constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } +threetenabp = { group = "com.jakewharton.threetenabp", name = "threetenabp", version.ref = "threetenabp" } +material-calendarview = { group = "com.prolificinteractive", name = "material-calendarview", version.ref = "material-calendarview" } +recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" } +transport-runtime = { group = "com.google.android.datatransport", name = "transport-runtime", version.ref = "transport-runtime" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" } +espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" } +activity = { group = "androidx.activity", name = "activity-ktx", version.ref = "activity" } +fragment = { group = "androidx.fragment", name = "fragment-ktx", version.ref = "fragment" } +databinding-compiler = { group = "com.android.databinding", name = "compiler", version.ref = "databinding-compiler" } + +retrofit = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" } +converter_gson = { group = "com.squareup.retrofit2", name = "converter-gson", version.ref = "converter-gson" } + +gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" } +okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" } +okhttp-logging-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" } + +glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" } +glide_compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide-compiler" } +compressor = { group = "id.zelory", name = "compressor", version.ref = "compressor" } + +coroutines = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" } +coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" } + +lifecycle_runtime = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime" } +lifecycle-viewmodel = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle-viewmodel" } +lifecycle-livedata = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycle-livedata" } + +kakao-login = { group = "com.kakao.sdk", name = "v2-user", version.ref = "kakao-login" } + +hilt = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" } +hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" } + + +play_services_base = { group = "com.google.android.gms", name = "play-services-base", version.ref = "play-services-base" } +firebase-config = { group = "com.google.firebase", name = "firebase-config-ktx", version.ref = "firebase-config" } +firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebase-bom" } +firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics-ktx" } +firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics" } + +timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" } + + +[plugins] +android-application = { id = "com.android.application", version.ref = "android" } +android-library = { id = "com.android.library", version.ref = "android" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin-android" } +google-services = { id = "com.google.gms.google-services", version.ref = "google-services" } +firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebase-crashlytics" } +hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }