Skip to content

Commit

Permalink
[feat] refactor build-logic, init network module (#21)
Browse files Browse the repository at this point in the history
* [build] kotlin-Serialization id 수정

* [init] network 모듈

* [build] hilt : migrate from kapt to ksp

* [build] kotlin config

* [build] testing 모듈에 JVM 플러그인 적용

* [build] ksp, hilt verson up

* [build] Build-logic refactoring
  • Loading branch information
murjune authored Jan 28, 2024
1 parent e1fdcd2 commit a5adb0f
Show file tree
Hide file tree
Showing 17 changed files with 224 additions and 123 deletions.
15 changes: 10 additions & 5 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ java {
dependencies {
compileOnly(libs.agp)
compileOnly(libs.kotlin.gradleplugin)
compileOnly(libs.ksp.gradlePlugin)
}

gradlePlugin {
Expand All @@ -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"
}
Expand All @@ -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"
}
}
}
Original file line number Diff line number Diff line change
@@ -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<Project> {
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<ApplicationExtension> {
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"))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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<Project> {
override fun apply(target: Project) =
override fun apply(target: Project) {
with(target) {
plugins.apply("com.android.library")
configureAndroidCommonPlugin()
apply<AndroidLibraryPlugin>()

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"))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ class AndroidHiltPlugin : Plugin<Project> {
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())
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<Project> {
override fun apply(target: Project) =
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("kotlin-android")
}
configureAndroidCommonPlugin()

extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
defaultConfig.targetSdk = libs.findVersion("targetSdk").get().requiredVersion.toInt()
}

dependencies {
add("testImplementation", kotlin("test"))
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("org.jetbrains.kotlin.jvm")
}
configureKotlinJvm()
}
}
}
Original file line number Diff line number Diff line change
@@ -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<AndroidHiltPlugin>()

extensions.getByType<BaseExtension>().apply {
buildFeatures.apply {
buildConfig = true
}
}

dependencies {
add("implementation", libs.findLibrary("timber").get())
}
}
Original file line number Diff line number Diff line change
@@ -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<JavaPluginExtension> {
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<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
}
}
7 changes: 1 addition & 6 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.funch.android.kotlin)
alias(libs.plugins.funch.android.library)
alias(libs.plugins.funch.compose)
}

android {
namespace = "com.moya.funch.designsystem"
}

dependencies {
implementation(libs.timber)
}

1 change: 1 addition & 0 deletions core/network/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Loading

0 comments on commit a5adb0f

Please sign in to comment.