diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index 0312d3b5..dfb10801 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -12,6 +12,7 @@ java { dependencies { compileOnly(libs.agp) compileOnly(libs.kotlin.gradleplugin) + compileOnly(libs.ksp.gradlePlugin) } gradlePlugin { @@ -21,20 +22,20 @@ gradlePlugin { implementationClass = "com.moya.funch.plugins.AndroidApplicationPlugin" } + create("android-library") { + id = "com.moya.funch.library" + implementationClass = "com.moya.funch.plugins.AndroidLibraryPlugin" + } create("android-feature") { id = "com.moya.funch.feature" implementationClass = "com.moya.funch.plugins.AndroidFeaturePlugin" } - create("android-kotlin") { - id = "com.moya.funch.android.kotlin" - implementationClass = "com.moya.funch.plugins.AndroidKotlinPlugin" - } create("android-hilt") { id = "com.moya.funch.hilt" implementationClass = "com.moya.funch.plugins.AndroidHiltPlugin" } create("kotlin-serialization") { - id = "com.moya.funch.serialization" + id = "com.moya.funch.kotlinx_serialization" implementationClass = "com.moya.funch.plugins.KotlinSerializationPlugin" } @@ -50,5 +51,9 @@ gradlePlugin { id = "com.moya.funch.compose" implementationClass = "com.moya.funch.plugins.ComposePlugin" } + register("jvm-library") { + id = "com.moya.funch.jvm.library" + implementationClass = "com.moya.funch.plugins.JvmLibraryPlugin" + } } } diff --git a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidApplicationPlugin.kt b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidApplicationPlugin.kt index ae062fb2..ee5c04a1 100644 --- a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidApplicationPlugin.kt +++ b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidApplicationPlugin.kt @@ -1,12 +1,36 @@ package com.moya.funch.plugins +import com.android.build.api.dsl.ApplicationExtension +import com.moya.funch.plugins.utils.configureAndroidCommonPlugin +import com.moya.funch.plugins.utils.configureKotlinAndroid +import com.moya.funch.plugins.utils.libs import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.kotlin class AndroidApplicationPlugin : Plugin { - override fun apply(target: Project) = + override fun apply(target: Project) { with(target) { - plugins.apply("com.android.application") + with(pluginManager) { + apply("com.android.application") + apply("kotlin-android") + } configureAndroidCommonPlugin() + + extensions.configure { + configureKotlinAndroid(this) + defaultConfig.targetSdk = libs.findVersion("targetSdk").get().requiredVersion.toInt() + } + + dependencies { + add("implementation", libs.findLibrary("core.ktx").get()) + add("implementation", libs.findLibrary("appcompat").get()) + add("implementation", libs.findBundle("lifecycle").get()) + add("implementation", libs.findLibrary("material").get()) + add("testImplementation", kotlin("test")) + } } + } } diff --git a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidFeaturePlugin.kt b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidFeaturePlugin.kt index ee263b8d..2f109b16 100644 --- a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidFeaturePlugin.kt +++ b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidFeaturePlugin.kt @@ -1,12 +1,25 @@ package com.moya.funch.plugins +import com.moya.funch.plugins.utils.configureAndroidCommonPlugin +import com.moya.funch.plugins.utils.libs import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.kotlin class AndroidFeaturePlugin : Plugin { - override fun apply(target: Project) = + override fun apply(target: Project) { with(target) { - plugins.apply("com.android.library") - configureAndroidCommonPlugin() + apply() + + dependencies { + add("implementation", libs.findLibrary("core.ktx").get()) + add("implementation", libs.findLibrary("appcompat").get()) + add("implementation", libs.findBundle("lifecycle").get()) + add("implementation", libs.findLibrary("material").get()) + add("testImplementation", kotlin("test")) + } } + } } diff --git a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidHiltPlugin.kt b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidHiltPlugin.kt index a03d3c91..4f98accd 100644 --- a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidHiltPlugin.kt +++ b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidHiltPlugin.kt @@ -9,14 +9,13 @@ class AndroidHiltPlugin : Plugin { override fun apply(target: Project) = with(target) { with(plugins) { - apply("com.google.dagger.hilt.android") + apply("com.google.devtools.ksp") + apply("dagger.hilt.android.plugin") } dependencies { - add("implementation", libs.findLibrary("hilt").get()) - add("kapt", libs.findLibrary("hilt.kapt").get()) - add("testImplementation", libs.findLibrary("hilt.testing").get()) - add("kaptTest", libs.findLibrary("hilt.testing.compiler").get()) + add("implementation", libs.findLibrary("hilt.android").get()) + add("ksp", libs.findLibrary("hilt.compiler").get()) } } } diff --git a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidKotlinPlugin.kt b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidKotlinPlugin.kt deleted file mode 100644 index 772c2452..00000000 --- a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidKotlinPlugin.kt +++ /dev/null @@ -1,46 +0,0 @@ -package com.moya.funch.plugins - -import com.android.build.gradle.BaseExtension -import com.moya.funch.plugins.utils.libs -import org.gradle.api.JavaVersion -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.plugins.ExtensionAware -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.getByType -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions - -class AndroidKotlinPlugin : Plugin { - override fun apply(target: Project) = - with(target) { - with(plugins) { - apply("kotlin-android") - } - - extensions.getByType().apply { - setCompileSdkVersion(libs.findVersion("compileSdk").get().requiredVersion.toInt()) - - defaultConfig { - minSdk = libs.findVersion("minSdk").get().requiredVersion.toInt() - targetSdk = libs.findVersion("targetSdk").get().requiredVersion.toInt() - } - - compileOptions { - isCoreLibraryDesugaringEnabled = true - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - (this as ExtensionAware).configure { - jvmTarget = "17" - } - } - - dependencies { - add("coreLibraryDesugaring", libs.findLibrary("desugarLibs").get()) - add("implementation", libs.findLibrary("kotlin").get()) - add("implementation", libs.findLibrary("kotlin.coroutines.android").get()) - } - } -} diff --git a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidLibraryPlugin.kt b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidLibraryPlugin.kt new file mode 100644 index 00000000..f3777c66 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/AndroidLibraryPlugin.kt @@ -0,0 +1,31 @@ +package com.moya.funch.plugins + +import com.android.build.gradle.LibraryExtension +import com.moya.funch.plugins.utils.configureAndroidCommonPlugin +import com.moya.funch.plugins.utils.configureKotlinAndroid +import com.moya.funch.plugins.utils.libs +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.kotlin + +class AndroidLibraryPlugin : Plugin { + override fun apply(target: Project) = + with(target) { + with(pluginManager) { + apply("com.android.library") + apply("kotlin-android") + } + configureAndroidCommonPlugin() + + extensions.configure { + configureKotlinAndroid(this) + defaultConfig.targetSdk = libs.findVersion("targetSdk").get().requiredVersion.toInt() + } + + dependencies { + add("testImplementation", kotlin("test")) + } + } +} diff --git a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/CommonConfigs.kt b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/CommonConfigs.kt deleted file mode 100644 index 7e0b3845..00000000 --- a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/CommonConfigs.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.moya.funch.plugins - -import com.android.build.gradle.BaseExtension -import com.moya.funch.plugins.utils.libs -import org.gradle.api.Project -import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.getByType - -internal fun Project.configureAndroidCommonPlugin() { - // val properties = - // Properties().apply { - // load(rootProject.file("local.properties").inputStream()) - // } - - apply() - apply() - with(plugins) { - apply("kotlin-kapt") - apply("kotlin-parcelize") - } - apply() - - extensions.getByType().apply { - defaultConfig { -// val kakaoApiKey = properties["kakaoApiKey"] as? String ?: "" -// val punchBaseUrl = properties["punchBaseUrl"] as? String ?: "" -// -// manifestPlaceholders["kakaoApiKey"] = properties["kakaoApiKey"] as String -// manifestPlaceholders["punchBaseUrl"] = properties["punchBaseUrl"] as String -// -// buildConfigField("String", "KAKAO_API_KEY", "\"${kakaoApiKey}\"") -// buildConfigField("String", "BASE_URL", "\"${punchBaseUrl}\"") - } - buildFeatures.apply { - buildConfig = true - } - } - - dependencies { - add("implementation", libs.findLibrary("core.ktx").get()) - add("implementation", libs.findLibrary("appcompat").get()) - add("implementation", libs.findBundle("lifecycle").get()) - add("implementation", libs.findLibrary("material").get()) - add("implementation", libs.findLibrary("timber").get()) - } -} diff --git a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/JvmLibraryPlugin.kt b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/JvmLibraryPlugin.kt new file mode 100644 index 00000000..d42d2c87 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/JvmLibraryPlugin.kt @@ -0,0 +1,19 @@ +package com.moya.funch.plugins + +import com.moya.funch.plugins.utils.configureKotlinJvm +import org.gradle.api.Plugin +import org.gradle.api.Project + +/** + * 순수 JVM 라이브러리를 위한 플러그인 ex) domain + * */ +class JvmLibraryPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("org.jetbrains.kotlin.jvm") + } + configureKotlinJvm() + } + } +} diff --git a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/utils/AndroidCommonConfigs.kt b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/utils/AndroidCommonConfigs.kt new file mode 100644 index 00000000..28e27469 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/utils/AndroidCommonConfigs.kt @@ -0,0 +1,22 @@ +package com.moya.funch.plugins.utils + +import com.android.build.gradle.BaseExtension +import com.moya.funch.plugins.AndroidHiltPlugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.getByType + +internal fun Project.configureAndroidCommonPlugin() { + apply() + + extensions.getByType().apply { + buildFeatures.apply { + buildConfig = true + } + } + + dependencies { + add("implementation", libs.findLibrary("timber").get()) + } +} diff --git a/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/utils/KotlinConfigs.kt b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/utils/KotlinConfigs.kt new file mode 100644 index 00000000..510ef124 --- /dev/null +++ b/build-logic/convention/src/main/kotlin/com/moya/funch/plugins/utils/KotlinConfigs.kt @@ -0,0 +1,67 @@ +package com.moya.funch.plugins.utils + +import com.android.build.api.dsl.CommonExtension +import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +/** + * Configure base Kotlin with Android options + */ +internal fun Project.configureKotlinAndroid( + commonExtension: CommonExtension<*, *, *, *, *>, +) { + commonExtension.apply { + compileSdk = libs.findVersion("compileSdk").get().requiredVersion.toInt() + + defaultConfig { + minSdk = libs.findVersion("minSdk").get().requiredVersion.toInt() + } + + compileOptions { + isCoreLibraryDesugaringEnabled = true + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + } + + configureKotlin() + + dependencies { + add("coreLibraryDesugaring", libs.findLibrary("desugarLibs").get()) + add("implementation", libs.findLibrary("kotlin").get()) + add("implementation", libs.findLibrary("kotlin.coroutines.android").get()) + } +} + +/** + * Configure base Kotlin options for JVM (non-Android) + */ +internal fun Project.configureKotlinJvm() { + extensions.configure { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + configureKotlin() + + dependencies { + add("implementation", libs.findLibrary("kotlin").get()) + add("implementation", libs.findLibrary("kotlin.coroutines.core").get()) + } +} + +/** + * Configure base Kotlin options + */ +private fun Project.configureKotlin() { + tasks.withType().configureEach { + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17.toString() + } + } +} diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index e90ef12f..1b0fff9a 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -1,6 +1,5 @@ plugins { - alias(libs.plugins.android.library) - alias(libs.plugins.funch.android.kotlin) + alias(libs.plugins.funch.android.library) alias(libs.plugins.funch.compose) } @@ -8,7 +7,3 @@ android { namespace = "com.moya.funch.designsystem" } -dependencies { - implementation(libs.timber) -} - diff --git a/core/network/.gitignore b/core/network/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/core/network/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts new file mode 100644 index 00000000..72185de8 --- /dev/null +++ b/core/network/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + alias(libs.plugins.funch.android.library) +} + +android { + namespace = "com.moja.funch.network" +} + +dependencies { + implementation(libs.bundles.retrofit) + implementation(platform(libs.okhttp.bom)) + implementation(libs.okhttp.logging.interceptor) +} diff --git a/core/network/src/main/java/com/moya/funch/network/MyClass.kt b/core/network/src/main/java/com/moya/funch/network/MyClass.kt new file mode 100644 index 00000000..6214831a --- /dev/null +++ b/core/network/src/main/java/com/moya/funch/network/MyClass.kt @@ -0,0 +1,4 @@ +package com.moya.funch.network + +class MyClass { +} \ No newline at end of file diff --git a/core/testing/build.gradle.kts b/core/testing/build.gradle.kts index 6c2202a6..b038e1cf 100644 --- a/core/testing/build.gradle.kts +++ b/core/testing/build.gradle.kts @@ -1,11 +1,10 @@ plugins { `java-library` - kotlin("jvm") + alias(libs.plugins.funch.jvm.library) } dependencies { implementation(libs.javax.inject) implementation(libs.bundles.junit5) - implementation(libs.kotlin.coroutines.core) implementation(libs.kotlin.coroutines.test) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d27deff6..1d3821ec 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,7 @@ navigation = "2.7.6" startup = "1.1.1" security = "1.1.0-alpha06" desugarJdk = "2.0.4" -dagger-hilt = "2.46.1" +dagger-hilt = "2.50" dagger-hilt-navigation-compose = "1.0.0" composeCompiler = "1.5.8" compose-bom = "2024.01.00" @@ -54,7 +54,7 @@ mock-webserver = "4.9.1" # gradle agp = "8.2.1" -kspplugin = "1.8.22-1.0.11" +ksp = "1.9.22-1.0.17" # third party okhttp = "4.12.0" @@ -73,6 +73,7 @@ agp = { module = "com.android.tools.build:gradle", version.ref = "agp" } # kotlin kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" } kotlin-gradleplugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } +ksp-gradlePlugin = { group = "com.google.devtools.ksp", name = "com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } kotlin-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" } # coroutines @@ -106,8 +107,8 @@ activity-compose = { group = "androidx.activity", name = "activity-compose", ver navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation" } # dagger-hilt -hilt = { module = "com.google.dagger:hilt-android", version.ref = "dagger-hilt" } -hilt-kapt = { module = "com.google.dagger:hilt-compiler", version.ref = "dagger-hilt" } +hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "dagger-hilt" } +hilt-compiler = { module = "com.google.dagger:hilt-compiler", name = "hilt-compiler", version.ref = "dagger-hilt" } hilt-plugin = { group = "com.google.dagger", name = "hilt-android-gradle-plugin", version.ref = "dagger-hilt" } hilt-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "dagger-hilt" } hilt-testing-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "dagger-hilt" } @@ -170,7 +171,7 @@ kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } dagger-hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger-hilt" } google-services = { id = "com.google.gms.google-services", version.ref = "google-services" } crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "crashlytics" } -ksp = { id = "com.google.devtools.ksp", version.ref = "kspplugin" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } secret = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secret-gradle-plugin" } kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } junit5 = { id = "de.mannodermaus.android-junit5", version.ref = "junit5-plugin" } @@ -179,13 +180,14 @@ ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } # Plugins defined by moya funch-application = { id = "com.moya.funch.application", version = "unspecified" } +funch-android-library = { id = "com.moya.funch.library", version = "unspecified" } funch-feature = { id = "com.moya.funch.feature", version = "unspecified" } -funch-android-kotlin = { id = "com.moya.funch.android.kotlin", version = "unspecified" } funch-hilt = { id = "com.moya.funch.hilt", version = "unspecified" } funch-kotlinx-serialization = { id = "com.moya.funch.kotlinx_serialization", version = "unspecified" } funch-android-test = { id = "com.moya.funch.android.test", version = "unspecified" } funch-junit5 = { id = "com.moya.funch.junit5", version = "unspecified" } funch-compose = { id = "com.moya.funch.compose", version = "unspecified" } +funch-jvm-library = { id = "com.moya.funch.jvm.library", version = "unspecified" } [bundles] firebase = ["firebase-analytics", "firebase-crashlytics"] diff --git a/settings.gradle.kts b/settings.gradle.kts index 60119888..edc5ce5c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,7 +22,7 @@ include(":app") // core include(":core:designsystem") include(":core:testing") -//include(":core:network") +include(":core:network") // feature include(":feature:profile")