From ac9683a8bc068cad0b007c0dc8616a46d5c8cbea Mon Sep 17 00:00:00 2001 From: "HyunWoo Lee (Nunu Lee)" <54518925+l2hyunwoo@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:36:22 +0900 Subject: [PATCH] Add Retrofit plugin (#445) * Add Retrofit plugin * Change import of serializaition converter factory * Remove redundant --- .idea/.gitignore | 2 ++ app/build.gradle.kts | 1 - build-logic/convention/build.gradle.kts | 4 ++++ .../pophory/plugin/CommonConfigs.kt | 1 + .../pophory/plugin/RetrofitPlugin.kt | 20 +++++++++++++++++++ core/common/build.gradle.kts | 1 - core/network/build.gradle.kts | 1 - .../pophory/network/di/NetModule.kt | 2 +- data/ad/build.gradle.kts | 1 - data/auth/build.gradle.kts | 1 - data/share/build.gradle.kts | 1 - feature/share/build.gradle.kts | 1 - gradle/libs.versions.toml | 10 +++++----- 13 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 build-logic/convention/src/main/kotlin/com/teampophory/pophory/plugin/RetrofitPlugin.kt diff --git a/.idea/.gitignore b/.idea/.gitignore index 26d33521..8f00030d 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,3 +1,5 @@ # Default ignored files /shelf/ /workspace.xml +# GitHub Copilot persisted chat sessions +/copilot/chatSessions diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 54a97a58..275e71a2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -102,7 +102,6 @@ dependencies { // Third Party implementation(libs.dot.indicator) implementation(libs.coil.core) - implementation(libs.bundles.retrofit) implementation(libs.kakao.login) implementation(libs.zxing.android.embedded) diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index ee7c5ab3..faaf26a1 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -48,5 +48,9 @@ gradlePlugin { id = "com.teampophory.pophory.compose" implementationClass = "com.teampophory.pophory.plugin.ComposePlugin" } + create("retrofit") { + id = "com.teampophory.pophory.retrofit" + implementationClass = "com.teampophory.pophory.plugin.RetrofitPlugin" + } } } diff --git a/build-logic/convention/src/main/kotlin/com/teampophory/pophory/plugin/CommonConfigs.kt b/build-logic/convention/src/main/kotlin/com/teampophory/pophory/plugin/CommonConfigs.kt index 84535a62..ba640685 100644 --- a/build-logic/convention/src/main/kotlin/com/teampophory/pophory/plugin/CommonConfigs.kt +++ b/build-logic/convention/src/main/kotlin/com/teampophory/pophory/plugin/CommonConfigs.kt @@ -15,6 +15,7 @@ internal fun Project.configureAndroidCommonPlugin() { apply() apply() + apply() with(plugins) { apply("kotlin-parcelize") } diff --git a/build-logic/convention/src/main/kotlin/com/teampophory/pophory/plugin/RetrofitPlugin.kt b/build-logic/convention/src/main/kotlin/com/teampophory/pophory/plugin/RetrofitPlugin.kt new file mode 100644 index 00000000..249463b9 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/com/teampophory/pophory/plugin/RetrofitPlugin.kt @@ -0,0 +1,20 @@ +package com.teampophory.pophory.plugin + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.getByType + +class RetrofitPlugin : Plugin { + override fun apply(target: Project) = with(target) { + val libs = extensions.getByType().named("libs") + + dependencies { + "implementation"(platform(libs.findLibrary("retrofit-bom").get())) + "implementation"(libs.findLibrary("retrofit").get()) + "implementation"(libs.findLibrary("retrofit-kotlin-serialization-converter").get()) + "implementation"(libs.findLibrary("retrofit-response-type-keeper").get()) + } + } +} diff --git a/core/common/build.gradle.kts b/core/common/build.gradle.kts index cdf426ed..d3a60dbe 100644 --- a/core/common/build.gradle.kts +++ b/core/common/build.gradle.kts @@ -13,5 +13,4 @@ android { dependencies { implementation(libs.fragment.ktx) - implementation(libs.retrofit) } diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index 46aeeb11..a876e74b 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -10,7 +10,6 @@ android { dependencies { implementation(projects.core.common) implementation(libs.security) - implementation(libs.bundles.retrofit) implementation(platform(libs.okhttp.bom)) implementation(libs.okhttp.logging.interceptor) implementation(libs.kakao.login) diff --git a/core/network/src/main/java/com/teampophory/pophory/network/di/NetModule.kt b/core/network/src/main/java/com/teampophory/pophory/network/di/NetModule.kt index 7d05b097..07e211f2 100644 --- a/core/network/src/main/java/com/teampophory/pophory/network/di/NetModule.kt +++ b/core/network/src/main/java/com/teampophory/pophory/network/di/NetModule.kt @@ -1,6 +1,5 @@ package com.teampophory.pophory.network.di -import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import com.teampophory.pophory.common.qualifier.Auth import com.teampophory.pophory.common.qualifier.Log import com.teampophory.pophory.common.qualifier.Secured @@ -22,6 +21,7 @@ import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Converter import retrofit2.Retrofit +import retrofit2.converter.kotlinx.serialization.asConverterFactory import java.util.concurrent.TimeUnit import javax.inject.Singleton diff --git a/data/ad/build.gradle.kts b/data/ad/build.gradle.kts index 244c6dec..a671510a 100644 --- a/data/ad/build.gradle.kts +++ b/data/ad/build.gradle.kts @@ -12,6 +12,5 @@ dependencies { implementation(projects.core.common) implementation(projects.core.network) implementation(libs.security) - implementation(libs.bundles.retrofit) implementation(libs.sentry) } diff --git a/data/auth/build.gradle.kts b/data/auth/build.gradle.kts index b7175e4f..9b4f2097 100644 --- a/data/auth/build.gradle.kts +++ b/data/auth/build.gradle.kts @@ -12,7 +12,6 @@ dependencies { implementation(projects.core.common) implementation(projects.core.network) implementation(libs.security) - implementation(libs.bundles.retrofit) implementation(libs.process.phoenix) implementation(libs.sentry) } diff --git a/data/share/build.gradle.kts b/data/share/build.gradle.kts index 4d3e1a52..974c94b2 100644 --- a/data/share/build.gradle.kts +++ b/data/share/build.gradle.kts @@ -10,5 +10,4 @@ dependencies { implementation(projects.domain.share) implementation(projects.core.common) implementation(projects.core.network) - implementation(libs.bundles.retrofit) } \ No newline at end of file diff --git a/feature/share/build.gradle.kts b/feature/share/build.gradle.kts index 6499d047..7c1fda6f 100644 --- a/feature/share/build.gradle.kts +++ b/feature/share/build.gradle.kts @@ -28,5 +28,4 @@ dependencies { // Third Party implementation(libs.coil.core) - implementation(libs.retrofit) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dcdd6b30..5ef4545c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,6 @@ versionCode = "10200" # kotlin kotlin = "1.9.23" kotlinx-serialization-json = "1.6.3" -kotlinx-serialization-converter = "1.0.0" kotlinx-coroutines = "1.8.0" kotlinx-datetime = "0.5.0" @@ -67,7 +66,7 @@ kspplugin = "1.9.23-1.0.19" flipper = "0.250.0" soloader = "0.11.0" okhttp = "4.12.0" -retrofit = "2.9.0" +retrofit = "2.10.0" timber = "5.0.1" coil = "2.6.0" lottie = "6.0.1" @@ -179,8 +178,10 @@ okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttp okhttp = { module = "com.squareup.okhttp3:okhttp" } okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor" } -retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } -retrofit-kotlin-serialization-converter = { group = "com.jakewharton.retrofit", name = "retrofit2-kotlinx-serialization-converter", version.ref = "kotlinx-serialization-converter" } +retrofit-bom = { module = "com.squareup.retrofit2:retrofit-bom", version.ref = "retrofit" } +retrofit = { module = "com.squareup.retrofit2:retrofit" } +retrofit-kotlin-serialization-converter = { group = "com.squareup.retrofit2", name = "converter-kotlinx-serialization" } +retrofit-response-type-keeper = { module = "com.squareup.retrofit2:response-type-keeper" } timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" } @@ -220,6 +221,5 @@ firebase = ["firebase-analytics", "firebase-crashlytics", "firebase-dynamiclink" flipper = ["flipper", "soloader", "flipper-network"] lifecycle = ["lifecycle", "lifecycle-viewmodel", "lifecycle-livedata"] compose = ["ui", "ui-graphics", "ui-tooling", "ui-tooling-preview", "material3-compose", "coil-compose", "ui-foundation", "activity-compose", "lifecycle-compose", "navigation-compose"] -retrofit = ["retrofit", "retrofit-kotlin-serialization-converter"] junit5 = ["junit5", "junit5-engine", "junit5-params", "junit5-vintage", "junit5-android-test-core", "junit5-android-test-runner"] androidx-android-test = ["androidx-test-core", "androidx-test-espresso", "androidx-test-espresso-intents", "androidx-test-junit", "androidx-test-junit-ktx", "androidx-test-rules", "androidx-test-runner", "androidx-test-truth"]