Add truth for better badging diff output

Change-Id: Id3fab0107bc08adf44ddf07a30e0327e06897d47
pull/1085/head
Alex Vanyo 12 months ago
parent 646c9cf4de
commit 5df9cce37c

@ -41,6 +41,7 @@ dependencies {
compileOnly(libs.firebase.performance.gradlePlugin) compileOnly(libs.firebase.performance.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin) compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.ksp.gradlePlugin) compileOnly(libs.ksp.gradlePlugin)
implementation(libs.truth)
} }
tasks { tasks {

@ -20,8 +20,8 @@ import com.android.build.api.artifact.SingleArtifact
import com.android.build.api.variant.ApplicationAndroidComponentsExtension import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import com.android.build.gradle.BaseExtension import com.android.build.gradle.BaseExtension
import com.android.SdkConstants import com.android.SdkConstants
import com.google.common.truth.Truth.assertWithMessage
import org.gradle.api.DefaultTask import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty import org.gradle.api.file.RegularFileProperty
@ -40,7 +40,6 @@ import org.gradle.kotlin.dsl.register
import org.gradle.language.base.plugins.LifecycleBasePlugin import org.gradle.language.base.plugins.LifecycleBasePlugin
import org.gradle.process.ExecOperations import org.gradle.process.ExecOperations
import java.io.File import java.io.File
import java.nio.file.Files
import javax.inject.Inject import javax.inject.Inject
@CacheableTask @CacheableTask
@ -98,17 +97,12 @@ abstract class CheckBadgingTask : DefaultTask() {
@TaskAction @TaskAction
fun taskAction() { fun taskAction() {
if ( assertWithMessage(
Files.mismatch( "Generated badging is different from golden badging! " +
goldenBadging.get().asFile.toPath(), "If this change is intended, run ./gradlew ${updateBadgingTaskName.get()}",
generatedBadging.get().asFile.toPath(), )
) != -1L .that(generatedBadging.get().asFile.readText())
) { .isEqualTo(goldenBadging.get().asFile.readText())
throw GradleException(
"Generated badging is different from golden badging! " +
"If this change is intended, run ./gradlew ${updateBadgingTaskName.get()}",
)
}
} }
} }

@ -57,6 +57,7 @@ robolectric = "4.11.1"
roborazzi = "1.6.0" roborazzi = "1.6.0"
room = "2.6.0" room = "2.6.0"
secrets = "2.0.1" secrets = "2.0.1"
truth = "1.1.5"
turbine = "1.0.0" turbine = "1.0.0"
[libraries] [libraries]
@ -140,6 +141,7 @@ roborazzi = { group = "io.github.takahirom.roborazzi", name = "roborazzi", versi
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" } room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" } room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" } room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" } turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" }
# Dependencies of the included build-logic # Dependencies of the included build-logic

Loading…
Cancel
Save