Gradle Management: Android Application Compose Convention Plugin - devrath/RunTracer GitHub Wiki
Compose blocks to replace
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
Define the convention
AndroidCompose.kt
internal fun Project.configureAndroidCompose(
commonExtension: CommonExtension<*, *, *, *, *, *>
) {
commonExtension.run {
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs
.findVersion("composeCompiler")
.get()
.toString()
//kotlinCompilerExtensionVersion = "1.5.1"
}
dependencies {
val bom = libs.findLibrary("androidx.compose.bom").get()
"implementation"(platform(bom))
"androidTestImplementation"(platform(bom))
"debugImplementation"(platform(bom))
//"debugImplementation"(libs.findLibrary("androidx.compose.ui.tooling.preview").get())
}
}
}
Register the convention
Add the code block in build-logic
build gradle
// Other code
gradlePlugin {
plugins {
// other registrations of convention
register("androidApplicationCompose") {
id = "runtracer.android.application.compose"
implementationClass = "AndroidApplicationComposeConventionPlugin"
}
}
}