Created
June 6, 2024 02:47
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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