JohnBuhanan
03/20/2024, 8:39 PMval composeAllowList = Providers.of(
setOf(
":foo:ui",
":bar:ui",
":etc:ui", // 40 such entries in here
)
)
fun Project.composeAllowList() {
val modulePath = path
tasks.withType(KotlinCompile::class.java).configureEach {
inputs.property("composeAllowList", composeAllowList)
doFirst {
// We check to see if the Compose Compiler plugin has been added to the compiler args.
val usingComposeCompiler =
kotlinOptions.freeCompilerArgs.any { it.contains("androidx.compose.compiler") }
if (usingComposeCompiler) {
val composeAllowlist = inputs.properties["composeAllowList"] as Set<String>
val moduleInComposeAllowlist = composeAllowlist.contains(modulePath)
// If the module is using Jetpack Compose but isn"t in the allowlist...💥
if (!moduleInComposeAllowlist && !modulePath.endsWith("twig")) {
throw GradleException("Module $modulePath is not in the allowlist for Compose!")
}
}
}
}
}