diff --git a/build-logic/convention/src/main/java/com/example/convention/configure/ApplicationConfigure.kt b/build-logic/convention/src/main/java/com/example/convention/configure/ApplicationConfigure.kt index a1c52b2..f9016a5 100644 --- a/build-logic/convention/src/main/java/com/example/convention/configure/ApplicationConfigure.kt +++ b/build-logic/convention/src/main/java/com/example/convention/configure/ApplicationConfigure.kt @@ -2,6 +2,8 @@ package com.example.convention.configure import com.android.build.gradle.internal.dsl.BaseAppModuleExtension import com.example.convention.constant.Constant +import com.example.convention.util.implementation +import com.example.convention.util.library import com.example.convention.util.libs import org.gradle.api.Project import org.gradle.kotlin.dsl.dependencies @@ -26,7 +28,5 @@ internal fun Project.applicationConfigure(extension: BaseAppModuleExtension) { } } - dependencies { - add("implementation", libs.findLibrary("androidx-core").get()) - } + dependencies { implementation(library("androidx-core")) } } \ No newline at end of file diff --git a/build-logic/convention/src/main/java/com/example/convention/configure/ComposeConfigure.kt b/build-logic/convention/src/main/java/com/example/convention/configure/ComposeConfigure.kt index 93d15ea..16319e2 100644 --- a/build-logic/convention/src/main/java/com/example/convention/configure/ComposeConfigure.kt +++ b/build-logic/convention/src/main/java/com/example/convention/configure/ComposeConfigure.kt @@ -1,27 +1,33 @@ package com.example.convention.configure -import com.example.convention.util.libs +import com.example.convention.util.androidTestImplementation +import com.example.convention.util.bundle +import com.example.convention.util.debugImplementation +import com.example.convention.util.implementation +import com.example.convention.util.library +import com.example.convention.util.testImplementation import org.gradle.api.Project import org.gradle.kotlin.dsl.dependencies internal fun Project.composeConfigure() { dependencies { // Jetpack Compose - val composeBom = platform(libs.findLibrary("compose-bom").get()) - add("implementation", composeBom) - add("implementation", libs.findBundle("compose").get()) - add("implementation", libs.findBundle("compose-lifecycle").get()) + val composeBom = platform(library("compose-bom")) - add("androidTestImplementation", composeBom) - add("androidTestImplementation", libs.findLibrary("compose-ui-junit4").get()) - add("debugImplementation", libs.findBundle("compose-debug").get()) + implementation(composeBom) + implementation(bundle("compose")) + implementation(bundle("compose-lifecycle")) + + androidTestImplementation(composeBom) + androidTestImplementation(library("compose-ui-junit4")) + debugImplementation(bundle("compose-debug")) // landscapist-glide - add("implementation", libs.findLibrary("landscapist-glide").get()) + implementation(library("landscapist-glide")) // Android Test - add("testImplementation", libs.findLibrary("junit").get()) - add("androidTestImplementation", libs.findLibrary("androidx-junit").get()) - add("androidTestImplementation", libs.findLibrary("androidx-test-espresso").get()) + testImplementation(library("junit")) + androidTestImplementation(library("androidx-junit")) + androidTestImplementation(library("androidx-test-espresso")) } } \ No newline at end of file diff --git a/build-logic/convention/src/main/java/com/example/convention/configure/DefaultLibraryConfigure.kt b/build-logic/convention/src/main/java/com/example/convention/configure/DefaultLibraryConfigure.kt index 6b9e0c5..35fec13 100644 --- a/build-logic/convention/src/main/java/com/example/convention/configure/DefaultLibraryConfigure.kt +++ b/build-logic/convention/src/main/java/com/example/convention/configure/DefaultLibraryConfigure.kt @@ -2,7 +2,8 @@ package com.example.convention.configure import com.android.build.gradle.LibraryExtension import com.example.convention.constant.Constant -import com.example.convention.util.libs +import com.example.convention.util.implementation +import com.example.convention.util.library import org.gradle.api.Project import org.gradle.kotlin.dsl.dependencies import org.jetbrains.kotlin.gradle.dsl.kotlinExtension @@ -19,7 +20,5 @@ internal fun Project.defaultLibraryConfigure(extension: LibraryExtension) { kotlinExtension.jvmToolchain(17) } - dependencies { - add("implementation", libs.findLibrary("androidx-core").get()) - } + dependencies { implementation(library("androidx-core")) } } \ No newline at end of file diff --git a/build-logic/convention/src/main/java/com/example/convention/configure/FeatureConfigure.kt b/build-logic/convention/src/main/java/com/example/convention/configure/FeatureConfigure.kt index 9338d61..170cfef 100644 --- a/build-logic/convention/src/main/java/com/example/convention/configure/FeatureConfigure.kt +++ b/build-logic/convention/src/main/java/com/example/convention/configure/FeatureConfigure.kt @@ -2,7 +2,14 @@ package com.example.convention.configure import com.android.build.gradle.LibraryExtension import com.example.convention.constant.Constant +import com.example.convention.util.androidTestImplementation +import com.example.convention.util.bundle +import com.example.convention.util.debugImplementation +import com.example.convention.util.implementation +import com.example.convention.util.ksp +import com.example.convention.util.library import com.example.convention.util.libs +import com.example.convention.util.testImplementation import org.gradle.api.Project import org.gradle.kotlin.dsl.dependencies import org.jetbrains.kotlin.gradle.dsl.kotlinExtension @@ -23,31 +30,31 @@ internal fun Project.featureConfigure(extension: LibraryExtension) { } dependencies { - add("implementation", libs.findLibrary("androidx-core").get()) + implementation(library("androidx-core")) // Kotlin Coroutines - add("implementation", libs.findLibrary("kotlinx-coroutines-android").get()) + implementation(library("kotlinx-coroutines-android")) // Dagger Hilt - add("implementation", libs.findLibrary("hilt").get()) - add("ksp", libs.findLibrary("hilt-compiler").get()) + implementation(library("hilt")) + ksp(library("hilt-compiler")) // Jetpack Compose - val composeBom = platform(libs.findLibrary("compose-bom").get()) - add("implementation", composeBom) - add("implementation", libs.findBundle("compose").get()) - add("implementation", libs.findBundle("compose-lifecycle").get()) + val composeBom = platform(library("compose-bom")) + implementation(composeBom) + implementation(bundle("compose")) + implementation(bundle("compose-lifecycle")) - add("androidTestImplementation", composeBom) - add("androidTestImplementation", libs.findLibrary("compose-ui-junit4").get()) - add("debugImplementation", libs.findBundle("compose-debug").get()) + androidTestImplementation(composeBom) + androidTestImplementation(library("compose-ui-junit4")) + debugImplementation(bundle("compose-debug")) // landscapist-glide - add("implementation", libs.findLibrary("landscapist-glide").get()) + implementation(library("landscapist-glide")) // Android Test - add("testImplementation", libs.findLibrary("junit").get()) - add("androidTestImplementation", libs.findLibrary("androidx-junit").get()) - add("androidTestImplementation", libs.findLibrary("androidx-test-espresso").get()) + testImplementation(library("junit")) + androidTestImplementation(library("androidx-junit")) + androidTestImplementation(library("androidx-test-espresso")) } } \ No newline at end of file diff --git a/build-logic/convention/src/main/java/com/example/convention/util/ConfUtils.kt b/build-logic/convention/src/main/java/com/example/convention/util/ConfUtils.kt new file mode 100644 index 0000000..b9fbd68 --- /dev/null +++ b/build-logic/convention/src/main/java/com/example/convention/util/ConfUtils.kt @@ -0,0 +1,24 @@ +package com.example.convention.util + +import org.gradle.api.artifacts.Dependency +import org.gradle.kotlin.dsl.support.delegates.DependencyHandlerDelegate + +internal fun DependencyHandlerDelegate.implementation(library: Any): Dependency? { + return add("implementation", library) +} + +internal fun DependencyHandlerDelegate.debugImplementation(library: Any): Dependency? { + return add("debugImplementation", library) +} + +internal fun DependencyHandlerDelegate.testImplementation(library: Any): Dependency? { + return add("testImplementation", library) +} + +internal fun DependencyHandlerDelegate.androidTestImplementation(library: Any): Dependency? { + return add("androidTestImplementation", library) +} + +internal fun DependencyHandlerDelegate.ksp(library: Any): Dependency? { + return add("ksp", library) +} diff --git a/build-logic/convention/src/main/java/com/example/convention/util/LibsUtil.kt b/build-logic/convention/src/main/java/com/example/convention/util/LibsUtil.kt deleted file mode 100644 index 1c9aa00..0000000 --- a/build-logic/convention/src/main/java/com/example/convention/util/LibsUtil.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.example.convention.util - -import org.gradle.api.Project -import org.gradle.api.artifacts.VersionCatalogsExtension -import org.gradle.kotlin.dsl.getByType - -internal val Project.libs - get() = extensions - .getByType() - .named("libs") \ No newline at end of file diff --git a/build-logic/convention/src/main/java/com/example/convention/util/LibsUtils.kt b/build-logic/convention/src/main/java/com/example/convention/util/LibsUtils.kt new file mode 100644 index 0000000..aa00b5c --- /dev/null +++ b/build-logic/convention/src/main/java/com/example/convention/util/LibsUtils.kt @@ -0,0 +1,29 @@ +package com.example.convention.util + +import org.gradle.api.Project +import org.gradle.api.artifacts.ExternalModuleDependencyBundle +import org.gradle.api.artifacts.MinimalExternalModuleDependency +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.api.artifacts.VersionConstraint +import org.gradle.api.provider.Provider +import org.gradle.kotlin.dsl.getByType +import org.gradle.plugin.use.PluginDependency + +internal val Project.libs + get() = extensions.getByType().named("libs") + +internal fun Project.version(alias: String): VersionConstraint { + return libs.findVersion(alias).get() +} + +internal fun Project.plugin(alias: String): Provider { + return libs.findPlugin(alias).get() +} + +internal fun Project.library(alias: String): Provider { + return libs.findLibrary(alias).get() +} + +internal fun Project.bundle(alias: String): Provider { + return libs.findBundle(alias).get() +}