Skip to content

Commit

Permalink
feat: 멀티 모듈화를 위한 패키지 분리 (#491)
Browse files Browse the repository at this point in the history
* feat: local 과 remote mapper 분리

* fix: 잘못 import된 코드 수정

* feat: local 및 remote 패키지 분리

* fix: 잘못된 import코드 수정

* feat: common 패키지 생성 및 변경

* feat: auth 패키지 분리

* style: ktlint 적용

* feat: remote 와 local 패키지 data로 이동

* style: ktlint 적용

* feat: error handler 관련 로직 common으로 이동

* refactor: 잘못된 의존성 관계 변경

* feat: DataStore을 common 패키지로 변경

* feat: build.gradle 중복 로직 수정 및 version catalog를 통한 관리

* fix: build 오류 수정

---------

Co-authored-by: Namyunsuk <[email protected]>
  • Loading branch information
2 people authored and ChooSeoyeon committed Sep 30, 2024
1 parent c0795a0 commit 3cc4521
Show file tree
Hide file tree
Showing 89 changed files with 384 additions and 347 deletions.
149 changes: 69 additions & 80 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ android {

buildTypes {
debug {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
isMinifyEnabled = false
}
release {
isMinifyEnabled = true
Expand Down Expand Up @@ -86,92 +82,85 @@ android {
}

dependencies {
val navigationVersion = "2.7.7"
val fragmentVersion = "1.8.1"
implementation("androidx.core:core-ktx:1.10.1")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.activity:activity-ktx:1.8.2")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.test.ext:junit-ktx:1.1.5")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
testImplementation("org.assertj:assertj-core:3.25.3")
testImplementation("io.kotest:kotest-runner-junit5:5.8.0")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
androidTestImplementation("org.assertj:assertj-core:3.25.3")
androidTestImplementation("io.kotest:kotest-runner-junit5:5.8.0")
androidTestImplementation("de.mannodermaus.junit5:android-test-core:1.3.0")
androidTestRuntimeOnly("de.mannodermaus.junit5:android-test-runner:1.3.0")
// Testing Navigation
androidTestImplementation("androidx.navigation:navigation-testing:$navigationVersion")

implementation("androidx.room:room-runtime:2.6.1")
kapt("androidx.room:room-compiler:2.6.1")
implementation("androidx.room:room-ktx:2.6.1")
implementation("com.google.code.gson:gson:2.8.8")

implementation("com.github.bumptech.glide:glide:4.12.0")
kapt("com.github.bumptech.glide:compiler:4.12.0")
testImplementation("androidx.arch.core:core-testing:2.1.0")
implementation("com.squareup.okhttp3:mockwebserver:4.12.0")

implementation("com.squareup.retrofit2:retrofit:2.11.0")
implementation("com.squareup.retrofit2:converter-gson:2.11.0")

implementation("androidx.room:room-ktx:2.6.1")

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0")

kapt("com.github.bumptech.glide:compiler:4.13.2")

implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
implementation("androidx.activity:activity-ktx:1.9.0")
implementation("androidx.fragment:fragment-ktx:1.7.0")
implementation("androidx.core:core-ktx:1.10.1")
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.activity)
implementation(libs.androidx.fragment)
implementation(libs.androidx.constraintlayout)

// Test
implementation(libs.androidx.junit)
testImplementation(libs.junit.jupiter)
testImplementation(libs.assertj.core)
testImplementation(libs.kotest.runner.junit5)
testImplementation(libs.core.testing)

// Android Test
androidTestImplementation(libs.junit.jupiter)
androidTestImplementation(libs.assertj.core)
androidTestImplementation(libs.kotest.runner.junit5)
androidTestImplementation(libs.mannodermaus.test.core)
androidTestImplementation(libs.mannodermaus.test.runner)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.test.runner)

// Espresso 및 관련
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(libs.androidx.espresso.contrib)

// UI Test: Fragment Scenario
debugImplementation(libs.androidx.fragment.testing)
androidTestImplementation(libs.androidx.fragment.testing)

// DataStore
implementation(libs.androidx.datastore.preferences)

// Lifecycle
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)

// Room
implementation(libs.androidx.room.runtime)
kapt(libs.androidx.room.compiler)
implementation(libs.androidx.room.ktx)

// json
implementation(libs.kotlinx.serialization.json)

// Glide
implementation(libs.glide)
kapt(libs.glide.compiler)

// Retrofit
implementation(libs.retrofit)
implementation(libs.retrofit.converter.gson)
implementation(libs.retrofit.kotlinx.serialization)

// Navigation
implementation("androidx.navigation:navigation-fragment-ktx:$navigationVersion")
implementation("androidx.navigation:navigation-ui-ktx:$navigationVersion")

// UI Test - Fragment Scenario
debugImplementation("androidx.fragment:fragment-testing-manifest:$fragmentVersion")
androidTestImplementation("androidx.fragment:fragment-testing:$fragmentVersion")

// Espresso
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test:runner:1.4.0")

// Espresso RecyclerView Actions
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.3.0")
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.navigation.ui)
androidTestImplementation(libs.androidx.navigation.testing)

// Pagination
implementation("androidx.paging:paging-runtime-ktx:3.3.0")
implementation(libs.androidx.paging.runtime)

// WebView
implementation("androidx.webkit:webkit:1.9.0")
implementation(libs.androidx.webkit)

// Firebase
implementation(platform("com.google.firebase:firebase-bom:33.1.2"))
implementation("com.google.firebase:firebase-analytics")
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
implementation(libs.firebase.crashlytics)

// 카카오 로그인
implementation("com.kakao.sdk:v2-all:2.20.3")

// data store
implementation("androidx.datastore:datastore-preferences:1.0.0")

implementation("com.google.firebase:firebase-crashlytics")
implementation(libs.kakao.sdk)

// mockk
testImplementation("io.mockk:mockk:1.13.10")
// Mockk
implementation(libs.mockwebserver)
testImplementation(libs.mockk)

// swipe refresh layout
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
// Swipe Refresh Layout
implementation(libs.androidx.swiperefreshlayout)
}
11 changes: 6 additions & 5 deletions android/app/src/main/java/com/zzang/chongdae/ChongdaeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ import android.content.Context
import androidx.datastore.preferences.preferencesDataStore
import com.google.firebase.FirebaseApp
import com.kakao.sdk.common.KakaoSdk
import com.zzang.chongdae.auth.repository.AuthRepository
import com.zzang.chongdae.auth.repository.AuthRepositoryImpl
import com.zzang.chongdae.auth.source.AuthRemoteDataSourceImpl
import com.zzang.chongdae.data.local.database.AppDatabase
import com.zzang.chongdae.data.local.source.OfferingLocalDataSourceImpl
import com.zzang.chongdae.data.remote.api.NetworkManager
import com.zzang.chongdae.data.remote.source.AuthRemoteDataSourceImpl
import com.zzang.chongdae.data.remote.source.CommentRemoteDataSourceImpl
import com.zzang.chongdae.data.remote.source.CommentRoomsDataSourceImpl
import com.zzang.chongdae.data.remote.source.OfferingDetailDataSourceImpl
import com.zzang.chongdae.data.remote.source.OfferingRemoteDataSourceImpl
import com.zzang.chongdae.data.remote.source.ParticipantRemoteDataSourceImpl
import com.zzang.chongdae.data.repository.AuthRepositoryImpl
import com.zzang.chongdae.data.repository.CommentDetailRepositoryImpl
import com.zzang.chongdae.data.repository.CommentRoomsRepositoryImpl
import com.zzang.chongdae.data.repository.OfferingDetailRepositoryImpl
import com.zzang.chongdae.data.repository.OfferingRepositoryImpl
import com.zzang.chongdae.data.repository.ParticipantRepositoryImpl
import com.zzang.chongdae.domain.repository.AuthRepository
import com.zzang.chongdae.domain.repository.CommentDetailRepository
import com.zzang.chongdae.domain.repository.CommentRoomsRepository
import com.zzang.chongdae.domain.repository.OfferingDetailRepository
Expand All @@ -29,7 +28,9 @@ import com.zzang.chongdae.domain.repository.ParticipantRepository

class ChongdaeApp : Application() {
private val appDatabase: AppDatabase by lazy { AppDatabase.getInstance(this) }
private val networkManager: NetworkManager by lazy { NetworkManager }
private val networkManager: com.zzang.chongdae.data.remote.api.NetworkManager by lazy {
com.zzang.chongdae.data.remote.api.NetworkManager
}

private val offeringDao by lazy { appDatabase.offeringDao() }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.zzang.chongdae.data.remote.api
package com.zzang.chongdae.auth.api

import com.zzang.chongdae.data.remote.dto.request.AccessTokenRequest
import com.zzang.chongdae.data.remote.dto.response.auth.MemberResponse
import com.zzang.chongdae.auth.dto.request.AccessTokenRequest
import com.zzang.chongdae.auth.dto.response.MemberResponse
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.POST
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zzang.chongdae.data.remote.dto.request
package com.zzang.chongdae.auth.dto.request

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zzang.chongdae.data.remote.dto.response.auth
package com.zzang.chongdae.auth.dto.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.zzang.chongdae.auth.mapper

import com.zzang.chongdae.auth.dto.response.MemberResponse
import com.zzang.chongdae.auth.model.Member

fun MemberResponse.toDomain(): Member {
return Member(
memberId = this.memberId,
nickName = this.nickname,
)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zzang.chongdae.domain.model
package com.zzang.chongdae.auth.model

data class Member(
val memberId: Long,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.zzang.chongdae.auth.repository

import com.zzang.chongdae.auth.model.Member
import com.zzang.chongdae.common.handler.DataError
import com.zzang.chongdae.common.handler.Result

interface AuthRepository {
suspend fun saveLogin(accessToken: String): Result<Member, DataError.Network>

suspend fun saveRefresh(): Result<Unit, DataError.Network>
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.zzang.chongdae.data.repository
package com.zzang.chongdae.auth.repository

import com.zzang.chongdae.data.mapper.toDomain
import com.zzang.chongdae.data.remote.dto.request.AccessTokenRequest
import com.zzang.chongdae.data.source.AuthRemoteDataSource
import com.zzang.chongdae.domain.model.Member
import com.zzang.chongdae.domain.repository.AuthRepository
import com.zzang.chongdae.domain.util.DataError
import com.zzang.chongdae.domain.util.Result
import com.zzang.chongdae.auth.dto.request.AccessTokenRequest
import com.zzang.chongdae.auth.mapper.toDomain
import com.zzang.chongdae.auth.model.Member
import com.zzang.chongdae.auth.source.AuthRemoteDataSource
import com.zzang.chongdae.common.handler.DataError
import com.zzang.chongdae.common.handler.Result

class AuthRepositoryImpl(
private val authRemoteDataSource: AuthRemoteDataSource,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.zzang.chongdae.auth.source

import com.zzang.chongdae.auth.dto.request.AccessTokenRequest
import com.zzang.chongdae.auth.dto.response.MemberResponse
import com.zzang.chongdae.common.handler.DataError
import com.zzang.chongdae.common.handler.Result

interface AuthRemoteDataSource {
suspend fun saveLogin(accessTokenRequest: AccessTokenRequest): Result<MemberResponse, DataError.Network>

suspend fun saveRefresh(): Result<Unit, DataError.Network>
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.zzang.chongdae.data.remote.source
package com.zzang.chongdae.auth.source

import com.zzang.chongdae.data.remote.api.AuthApiService
import com.zzang.chongdae.data.remote.dto.request.AccessTokenRequest
import com.zzang.chongdae.data.remote.dto.response.auth.MemberResponse
import com.zzang.chongdae.auth.api.AuthApiService
import com.zzang.chongdae.auth.dto.request.AccessTokenRequest
import com.zzang.chongdae.auth.dto.response.MemberResponse
import com.zzang.chongdae.common.handler.DataError
import com.zzang.chongdae.common.handler.Result
import com.zzang.chongdae.data.remote.util.safeApiCall
import com.zzang.chongdae.data.source.AuthRemoteDataSource
import com.zzang.chongdae.domain.util.DataError
import com.zzang.chongdae.domain.util.Result

class AuthRemoteDataSourceImpl(
private val service: AuthApiService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zzang.chongdae.data.local.source
package com.zzang.chongdae.common.datastore

import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zzang.chongdae.presentation.util
package com.zzang.chongdae.common.firebase

import android.os.Bundle
import com.google.firebase.analytics.FirebaseAnalytics
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zzang.chongdae.domain.util
package com.zzang.chongdae.common.handler

sealed interface DataError : Error {
enum class Network : DataError {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.zzang.chongdae.common.handler

sealed interface Error
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zzang.chongdae.domain.util
package com.zzang.chongdae.common.handler

typealias RootError = Error

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3cc4521

Please sign in to comment.