Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save malbanese/6f015e0390ee767c4bc0acb87f697755 to your computer and use it in GitHub Desktop.
Save malbanese/6f015e0390ee767c4bc0acb87f697755 to your computer and use it in GitHub Desktop.
Add Android Compose screenshot testing plugin and setup as a gradle convention plugin
class ComposeAndroidScreenshotTestConventionPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
pluginManager.apply("com.android.compose.screenshot")
android {
if (this !is CommonExtension<*, *, *, *, *, *>) {
throw RuntimeException("Expected module to be of base type CommonExtension")
}
@Suppress("UnstableApiUsage")
experimentalProperties["android.experimental.enableScreenshotTest"] = true
buildFeatures {
compose = true
}
dependencies {
"debugImplementation"("org.jetbrains.compose.ui:ui-tooling:${ComposeBuildConfig.composeVersion}")
}
}
}
}
private fun Project.android(action: BaseExtension.() -> Unit) =
extensions.configure<BaseExtension>(action)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment