Change app and library compose build plugins to share dependencies
This commit is contained in:
parent
bd6cde63b0
commit
7b4f3d796e
5 changed files with 42 additions and 24 deletions
|
@ -1,7 +1,8 @@
|
|||
import com.android.build.api.dsl.CommonExtension
|
||||
import org.gradle.accessors.dm.LibrariesForLibs
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||
|
||||
fun CommonExtension<*, *, *, *>.configureSharedConfig() {
|
||||
internal fun CommonExtension<*, *, *, *>.configureSharedConfig() {
|
||||
compileSdk = ThunderbirdProjectConfig.androidSdkCompile
|
||||
|
||||
defaultConfig {
|
||||
|
@ -28,7 +29,9 @@ fun CommonExtension<*, *, *, *>.configureSharedConfig() {
|
|||
}
|
||||
}
|
||||
|
||||
fun CommonExtension<*, *, *, *>.configureSharedComposeConfig(libs: LibrariesForLibs) {
|
||||
internal fun CommonExtension<*, *, *, *>.configureSharedComposeConfig(
|
||||
libs: LibrariesForLibs,
|
||||
) {
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
|
@ -48,3 +51,19 @@ fun CommonExtension<*, *, *, *>.configureSharedComposeConfig(libs: LibrariesForL
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun DependencyHandler.configureSharedComposeDependencies(
|
||||
libs: LibrariesForLibs,
|
||||
) {
|
||||
val composeBom = platform(libs.androidx.compose.bom)
|
||||
implementation(composeBom)
|
||||
androidTestImplementation(composeBom)
|
||||
|
||||
implementation(libs.bundles.shared.jvm.android.compose)
|
||||
|
||||
debugImplementation(libs.bundles.shared.jvm.android.compose.debug)
|
||||
|
||||
testImplementation(libs.bundles.shared.jvm.test.compose)
|
||||
|
||||
androidTestImplementation(libs.bundles.shared.jvm.androidtest.compose)
|
||||
}
|
||||
|
|
14
build-plugin/src/main/kotlin/DependencyHandlerExtension.kt
Normal file
14
build-plugin/src/main/kotlin/DependencyHandlerExtension.kt
Normal file
|
@ -0,0 +1,14 @@
|
|||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||
|
||||
internal fun DependencyHandler.implementation(dependencyNotation: Any): Dependency? =
|
||||
add("implementation", dependencyNotation)
|
||||
|
||||
internal fun DependencyHandler.debugImplementation(dependencyNotation: Any): Dependency? =
|
||||
add("debugImplementation", dependencyNotation)
|
||||
|
||||
internal fun DependencyHandler.testImplementation(dependencyNotation: Any): Dependency? =
|
||||
add("testImplementation", dependencyNotation)
|
||||
|
||||
internal fun DependencyHandler.androidTestImplementation(dependencyNotation: Any): Dependency? =
|
||||
add("androidTestImplementation", dependencyNotation)
|
|
@ -1,6 +1,10 @@
|
|||
import org.gradle.accessors.dm.LibrariesForLibs
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.DependencyHandlerScope
|
||||
import org.gradle.kotlin.dsl.getByName
|
||||
|
||||
val Project.libs: LibrariesForLibs
|
||||
internal val Project.libs: LibrariesForLibs
|
||||
get() = extensions.getByName<LibrariesForLibs>("libs")
|
||||
|
||||
internal fun Project.dependencies(configuration: DependencyHandlerScope.() -> Unit) =
|
||||
DependencyHandlerScope.of(dependencies).configuration()
|
||||
|
|
|
@ -17,16 +17,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
val composeBom = platform(libs.androidx.compose.bom)
|
||||
implementation(composeBom)
|
||||
androidTestImplementation(composeBom)
|
||||
configureSharedComposeDependencies(libs)
|
||||
|
||||
implementation(libs.bundles.shared.jvm.android.compose)
|
||||
implementation(libs.androidx.compose.activity)
|
||||
|
||||
debugImplementation(libs.bundles.shared.jvm.android.compose.debug)
|
||||
|
||||
testImplementation(libs.bundles.shared.jvm.test.compose)
|
||||
|
||||
androidTestImplementation(libs.bundles.shared.jvm.androidtest.compose)
|
||||
}
|
||||
|
|
|
@ -7,15 +7,5 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
val composeBom = platform(libs.androidx.compose.bom)
|
||||
implementation(composeBom)
|
||||
androidTestImplementation(composeBom)
|
||||
|
||||
implementation(libs.bundles.shared.jvm.android.compose)
|
||||
|
||||
debugImplementation(libs.bundles.shared.jvm.android.compose.debug)
|
||||
|
||||
testImplementation(libs.bundles.shared.jvm.test.compose)
|
||||
|
||||
androidTestImplementation(libs.bundles.shared.jvm.androidtest.compose)
|
||||
configureSharedComposeDependencies(libs)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue