Skip to content

Commit

Permalink
[CHORE]
Browse files Browse the repository at this point in the history
 - Add ConfUtils.kt
 - Mod LibsUtils.kt
 - Mod XXXConfigure.kt files
  • Loading branch information
KanuKim97 committed Nov 30, 2024
1 parent c6c7848 commit 8d27afb
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,7 +28,5 @@ internal fun Project.applicationConfigure(extension: BaseAppModuleExtension) {
}
}

dependencies {
add("implementation", libs.findLibrary("androidx-core").get())
}
dependencies { implementation(library("androidx-core")) }
}
Original file line number Diff line number Diff line change
@@ -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"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"))
}
}
Original file line number Diff line number Diff line change
@@ -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)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<VersionCatalogsExtension>().named("libs")

internal fun Project.version(alias: String): VersionConstraint {
return libs.findVersion(alias).get()
}

internal fun Project.plugin(alias: String): Provider<PluginDependency> {
return libs.findPlugin(alias).get()
}

internal fun Project.library(alias: String): Provider<MinimalExternalModuleDependency> {
return libs.findLibrary(alias).get()
}

internal fun Project.bundle(alias: String): Provider<ExternalModuleDependencyBundle> {
return libs.findBundle(alias).get()
}

0 comments on commit 8d27afb

Please sign in to comment.