-
Notifications
You must be signed in to change notification settings - Fork 1
멀티모듈 아키텍처 구조 설정 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9dd051a
5535aa5
0ec91a4
6e59559
5323bd0
71d95d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| ktlint_function_naming_ignore_when_annotated_with = Composable | ||
|
|
||
| [{*.kt,*.kts}] | ||
| ktlint_standard_package-name = disabled |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| plugins { | ||
| `kotlin-dsl` | ||
| } | ||
|
|
||
| group = "com.twix.convention" | ||
|
|
||
| java { | ||
| sourceCompatibility = JavaVersion.VERSION_17 | ||
| targetCompatibility = JavaVersion.VERSION_17 | ||
| } | ||
|
|
||
| kotlin { | ||
| jvmToolchain(17) | ||
| } | ||
|
|
||
| dependencies { | ||
| compileOnly(libs.android.gradle.plugin) | ||
| compileOnly(libs.kotlin.gradle.plugin) | ||
| compileOnly(libs.compose.gradle.plugin) | ||
| compileOnly(libs.ksp.gradle.plugin) | ||
| compileOnly(libs.android.junit5.gradle.plugin) | ||
| } | ||
|
|
||
| gradlePlugin { | ||
| plugins { | ||
| register("androidApplication"){ | ||
| id = "twix.android.application" | ||
| implementationClass = "com.twix.convention.AndroidApplicationConventionPlugin" | ||
| } | ||
| register("androidLibrary") { | ||
| id = "twix.android.library" | ||
| implementationClass = "com.twix.convention.AndroidLibraryConventionPlugin" | ||
| } | ||
| register("androidCompose"){ | ||
| id = "twix.android.compose" | ||
| implementationClass = "com.twix.convention.AndroidComposeConventionPlugin" | ||
| } | ||
| register("feature"){ | ||
| id = "twix.feature" | ||
| implementationClass = "com.twix.convention.FeatureConventionPlugin" | ||
| } | ||
| register("koin"){ | ||
| id = "twix.koin" | ||
| implementationClass = "com.twix.convention.KoinConventionPlugin" | ||
| } | ||
| register("javaLibrary"){ | ||
| id = "twix.java.library" | ||
| implementationClass = "com.twix.convention.JvmLibraryConventionPlugin" | ||
| } | ||
| register("data"){ | ||
| id = "twix.data" | ||
| implementationClass = "com.twix.convention.DataConventionPlugin" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.twix.convention | ||
|
|
||
| import com.android.build.api.dsl.ApplicationExtension | ||
| import com.twix.convention.extension.applyPlugins | ||
| import com.twix.convention.extension.configureAndroid | ||
| import com.twix.convention.extension.implementation | ||
| import com.twix.convention.extension.library | ||
| import com.twix.convention.extension.libs | ||
| import org.gradle.kotlin.dsl.configure | ||
| import org.gradle.kotlin.dsl.dependencies | ||
|
|
||
| class AndroidApplicationConventionPlugin : BuildLogicConventionPlugin({ | ||
| applyPlugins("com.android.application", "org.jetbrains.kotlin.android") | ||
|
|
||
| extensions.configure<ApplicationExtension> { | ||
| configureAndroid(this) | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.library("kotlinx-serialization-json")) | ||
| } | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.twix.convention | ||
|
|
||
| import com.android.build.api.dsl.ApplicationExtension | ||
| import com.android.build.api.dsl.LibraryExtension | ||
| import com.twix.convention.extension.* | ||
| import org.gradle.kotlin.dsl.configure | ||
| import org.gradle.kotlin.dsl.dependencies | ||
|
|
||
| class AndroidComposeConventionPlugin : BuildLogicConventionPlugin({ | ||
| applyPlugins("org.jetbrains.kotlin.plugin.compose") | ||
|
|
||
| pluginManager.withPlugin("com.android.application") { | ||
| extensions.configure<ApplicationExtension> { | ||
| configureCompose(this) | ||
| } | ||
| } | ||
|
|
||
| pluginManager.withPlugin("com.android.library") { | ||
| extensions.configure<LibraryExtension> { | ||
| configureCompose(this) | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| val bom = platform(libs.library("compose-bom")) | ||
| implementation(bom) | ||
| implementation(libs.bundle("compose")) | ||
| debugImplementation(libs.bundle("compose-debug")) | ||
| } | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.twix.convention | ||
|
|
||
| import com.android.build.api.dsl.LibraryExtension | ||
| import com.twix.convention.extension.* | ||
| import org.gradle.kotlin.dsl.configure | ||
| import org.gradle.kotlin.dsl.dependencies | ||
|
|
||
| class AndroidLibraryConventionPlugin : BuildLogicConventionPlugin({ | ||
| applyPlugins( | ||
| "com.android.library", | ||
| "org.jetbrains.kotlin.android", | ||
| "de.mannodermaus.android-junit5" | ||
| ) | ||
|
|
||
| extensions.configure<LibraryExtension> { | ||
| configureAndroid(this) | ||
| defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.library("kotlinx-coroutines-core")) | ||
| testImplementation(libs.bundle("test-unit")) | ||
| androidTestImplementation(libs.library("androidx-test-ext-junit")) | ||
| } | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.twix.convention | ||
|
|
||
| import org.gradle.api.Plugin | ||
| import org.gradle.api.Project | ||
|
|
||
| abstract class BuildLogicConventionPlugin(private val block: Project.() -> Unit) : Plugin<Project> { | ||
| final override fun apply(target: Project) { | ||
| with(target, block = block) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.twix.convention | ||
|
|
||
| import com.twix.convention.extension.* | ||
| import org.gradle.kotlin.dsl.dependencies | ||
|
|
||
| class DataConventionPlugin : BuildLogicConventionPlugin({ | ||
| applyPlugins( | ||
| "twix.android.library", | ||
| "org.jetbrains.kotlin.plugin.serialization", | ||
| "twix.koin" | ||
| ) | ||
|
Comment on lines
+7
to
+11
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저희가 직접 구현한 컨벤션 플러그인을 적용할 때는 apply를 사용해서 넣는 게 나중에 플러그인 코드 수정할 때나 무슨 내용이 들어있는지 파악할 때 더 편할 거 같아요 예를 들어서 이런식으로 수정하게 되면 커스텀 플러그인 내부에 어떤 내용이 들어있는지 IDE 네비게이션으로 바로 들어가서 확인할 수 있고 문자열로 하드코딩하면서 발생하는 실수도 방지할 수 있을 거 같아요
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| dependencies { | ||
| implementation(project(":domain")) | ||
| implementation(project(":core:network")) | ||
| } | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.twix.convention | ||
|
|
||
| import com.twix.convention.extension.implementation | ||
| import org.gradle.kotlin.dsl.apply | ||
| import org.gradle.kotlin.dsl.dependencies | ||
|
|
||
| class FeatureConventionPlugin : BuildLogicConventionPlugin({ | ||
| apply<AndroidLibraryConventionPlugin>() | ||
| apply<KoinConventionPlugin>() | ||
| apply<AndroidComposeConventionPlugin>() | ||
|
|
||
| dependencies { | ||
| implementation(project(":core:design-system")) | ||
| implementation(project(":core:navigation")) | ||
| implementation(project(":core:ui")) | ||
| implementation(project(":domain")) | ||
| } | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.twix.convention | ||
|
|
||
| import com.twix.convention.extension.* | ||
| import org.gradle.api.JavaVersion | ||
| import org.gradle.api.plugins.JavaPluginExtension | ||
| import org.gradle.api.tasks.testing.Test | ||
| import org.gradle.kotlin.dsl.configure | ||
| import org.gradle.kotlin.dsl.dependencies | ||
| import org.gradle.kotlin.dsl.withType | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension | ||
|
|
||
| class JvmLibraryConventionPlugin : BuildLogicConventionPlugin({ | ||
| applyPlugins("org.jetbrains.kotlin.jvm") | ||
|
|
||
| val javaVersionInt = libs.version("java").requiredVersion.toInt() | ||
| val javaVersion = JavaVersion.toVersion(javaVersionInt) | ||
|
|
||
| extensions.configure<JavaPluginExtension> { | ||
| sourceCompatibility = javaVersion | ||
| targetCompatibility = javaVersion | ||
| } | ||
|
|
||
| extensions.configure<KotlinProjectExtension> { | ||
| jvmToolchain(javaVersionInt) | ||
| } | ||
|
|
||
| tasks.withType<Test> { | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.library("kotlinx-coroutines-core-jvm")) | ||
| testImplementation(libs.bundle("test-unit")) | ||
| } | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.twix.convention | ||
|
|
||
| import com.twix.convention.extension.* | ||
| import org.gradle.kotlin.dsl.dependencies | ||
|
|
||
| class KoinConventionPlugin : BuildLogicConventionPlugin({ | ||
| dependencies { | ||
| implementation(platform(libs.library("koin-bom"))) | ||
| implementation(libs.bundle("koin")) | ||
| } | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.twix.convention.extension | ||
|
|
||
| import com.android.build.api.dsl.CommonExtension | ||
| import org.gradle.api.JavaVersion | ||
| import org.gradle.api.Project | ||
| import org.gradle.kotlin.dsl.configure | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension | ||
|
|
||
| internal fun Project.configureAndroid(extension: CommonExtension<*, *, *, *, *, *>) { | ||
| val javaVersionInt = libs.version("java").requiredVersion.toInt() | ||
| val javaVersion = JavaVersion.toVersion(javaVersionInt) | ||
|
|
||
| extension.apply { | ||
| compileSdk = libs.version("compileSdk").requiredVersion.toInt() | ||
|
|
||
| defaultConfig { | ||
| minSdk = libs.version("minSdk").requiredVersion.toInt() | ||
| } | ||
|
|
||
| compileOptions { | ||
| sourceCompatibility = javaVersion | ||
| targetCompatibility = javaVersion | ||
| } | ||
|
|
||
| extensions.configure<KotlinProjectExtension> { | ||
| jvmToolchain(javaVersionInt) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.twix.convention.extension | ||
|
|
||
| import com.android.build.api.dsl.CommonExtension | ||
| import org.gradle.api.Project | ||
| import org.gradle.kotlin.dsl.dependencies | ||
|
|
||
| internal fun Project.configureCompose(extension: CommonExtension<*, *, *, *, *, *>) { | ||
| extension.apply { | ||
| buildFeatures { | ||
| compose = true | ||
| } | ||
|
|
||
| dependencies { | ||
| val composeBom = libs.library("compose-bom") | ||
| implementation(platform(composeBom)) | ||
| implementation(libs.bundle("compose")) | ||
|
|
||
| androidTestImplementation(platform(composeBom)) | ||
| androidTestImplementation(libs.library("compose-ui-test-junit4")) | ||
| debugImplementation(libs.bundle("compose-debug")) | ||
|
|
||
| implementation(libs.library("material")) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.twix.convention.extension | ||
|
|
||
| import org.gradle.api.Project | ||
| import org.gradle.api.provider.Provider | ||
| import org.gradle.kotlin.dsl.DependencyHandlerScope | ||
|
|
||
| fun DependencyHandlerScope.implementation(project: Project) { | ||
| "implementation"(project) | ||
| } | ||
|
|
||
| fun DependencyHandlerScope.implementation(provider: Provider<*>) { | ||
| "implementation"(provider) | ||
| } | ||
|
|
||
| fun DependencyHandlerScope.debugImplementation(provider: Provider<*>) { | ||
| "debugImplementation"(provider) | ||
| } | ||
|
|
||
| fun DependencyHandlerScope.androidTestImplementation(provider: Provider<*>) { | ||
| "androidTestImplementation"(provider) | ||
| } | ||
|
|
||
| fun DependencyHandlerScope.testImplementation(provider: Provider<*>) { | ||
| "testImplementation"(provider) | ||
| } | ||
|
Comment on lines
+7
to
+25
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 함수로 뺄 생각은 못해봤는데 좋네요 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.twix.convention.extension | ||
|
|
||
| import org.gradle.api.Project | ||
| import org.gradle.api.artifacts.VersionCatalog | ||
| import org.gradle.api.artifacts.VersionCatalogsExtension | ||
| import org.gradle.kotlin.dsl.getByType | ||
|
|
||
| internal val Project.libs: VersionCatalog | ||
| get() = extensions.getByType<VersionCatalogsExtension>().named("libs") | ||
|
|
||
| internal fun Project.applyPlugins(vararg plugins: String) { | ||
| plugins.forEach(pluginManager::apply) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 이렇게 추상화해서 빼는 거 되게 좋을 거 같아요