From 4918281e4682a91f7560a801ef20d019978cb4d7 Mon Sep 17 00:00:00 2001 From: takahirom Date: Mon, 4 Nov 2024 17:27:29 +0900 Subject: [PATCH] Remove intermediate dir when roborazzi.deleteOldScreenshots --- .../io/github/takahirom/roborazzi/RoborazziPlugin.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include-build/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt b/include-build/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt index f5d2957d..735c6f28 100644 --- a/include-build/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt +++ b/include-build/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt @@ -419,6 +419,7 @@ abstract class RoborazziPlugin : Plugin { test = test, roborazziProperties = roborazziProperties, outputDir = outputDir, + intermediateDir = intermediateDir, roborazziResults = roborazziResults, ) @@ -558,10 +559,18 @@ abstract class RoborazziPlugin : Plugin { test: AbstractTestTask, roborazziProperties: Map, outputDir: DirectoryProperty, + intermediateDir: DirectoryProperty, roborazziResults: CaptureResults, ) { if (roborazziProperties["roborazzi.deleteOldScreenshots"] == "true") { - // Remove all files not in the results + // Delete all images from the intermediateDir + intermediateDir.get().asFile.walkTopDown().forEach { file -> + if (KnownImageFileExtensions.contains(file.extension)) { + file.delete() + } + } + + // Remove all files not in the results from the outputDir val removingFiles: MutableSet = outputDir.get().asFile .listFiles() ?.toList()