making use of the lazy task registration to allow only applying the paparazzi plugin when needed

This commit is contained in:
Adam Brown 2022-09-16 16:15:10 +01:00
parent dc0599f966
commit c0baa2e8fd

View File

@ -297,21 +297,24 @@ dependencyAnalysis {
} }
} }
task recordScreenshots(type: GradleBuild) { tasks.register("recordScreenshots", GradleBuild) {
startParameter.projectProperties.screenshot = "" startParameter.projectProperties.screenshot = ""
tasks = [':vector:recordPaparazziGplayDebug'] tasks = [':vector:recordPaparazziDebug']
} }
task verifyScreenshots(type: GradleBuild) { tasks.register("verifyScreenshots", GradleBuild) {
startParameter.projectProperties.screenshot = "" startParameter.projectProperties.screenshot = ""
tasks = [':vector:verifyPaparazziGplayDebug'] tasks = [':vector:verifyPaparazziDebug']
} }
ext.initScreenshotTests = { project -> ext.initScreenshotTests = { project ->
project.apply plugin: 'app.cash.paparazzi' def hasScreenshots = project.hasProperty("screenshot")
if (hasScreenshots) {
project.apply plugin: 'app.cash.paparazzi'
}
project.android.testOptions.unitTests.all { project.android.testOptions.unitTests.all {
def screenshotTestCapture = "**/*ScreenshotTest*" def screenshotTestCapture = "**/*ScreenshotTest*"
if (project.hasProperty("screenshot")) { if (hasScreenshots) {
include screenshotTestCapture include screenshotTestCapture
} else { } else {
exclude screenshotTestCapture exclude screenshotTestCapture