Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ dependencies {
// 프로젝트 의존성
implementation(projects.core.resource)
implementation(projects.core.designsystem)
implementation(projects.core.network)

// AndroidX 및 Jetpack 기본 라이브러리
implementation(libs.androidx.core.ktx)
Expand Down
1 change: 1 addition & 0 deletions core/network/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
34 changes: 34 additions & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import com.into.websoso.buildConfigs
import com.into.websoso.setNamespace

plugins {
id("websoso.android.library")
}

android {
setNamespace("core.network")
buildTypes {
debug {
buildConfigs(rootDir) {
string(name = "BASE_URL", key = "debug.base.url")
}
}

release {
buildConfigs(rootDir) {
string(name = "BASE_URL", key = "release.base.url")
}
}
}
buildFeatures {
buildConfig = true
}
}

dependencies {
implementation(libs.retrofit)
implementation(libs.retrofit.kotlinx.serialization)
implementation(libs.serialization.json)
implementation(libs.okhttp)
implementation(libs.okhttp.logging.interceptor)
}
Empty file added core/network/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions core/network/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
4 changes: 4 additions & 0 deletions core/network/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.into.websoso.core.network.di

import com.into.websoso.core.network.BuildConfig
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {
private const val BASE_URL = BuildConfig.BASE_URL
private const val CONTENT_TYPE = "application/json"

@Provides
@Singleton
fun provideRetrofit(
json: Json,
client: OkHttpClient,
): Retrofit =
Retrofit
.Builder()
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(json.asConverterFactory(CONTENT_TYPE.toMediaType()))
.build()

@Provides
@Singleton
internal fun provideJson(): Json = Json { ignoreUnknownKeys = true }

@Provides
@Singleton
internal fun provideOkHttpClient(): OkHttpClient =
OkHttpClient
.Builder()
.addInterceptor(
HttpLoggingInterceptor().apply {
if (BuildConfig.DEBUG) setLevel(HttpLoggingInterceptor.Level.BODY)
},
).build()
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ include(":app")
include(
":core:resource",
":core:designsystem",
":core:network",
)