Use specific task name for updating badging

Change-Id: I52b75fb3ed2ae3a76656c211b7aee1aa521f1112
pull/1014/head
Alex Vanyo 1 year ago
parent 3ccacba0fe
commit c70049edd8

@ -24,7 +24,9 @@ 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
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Copy import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.OutputFile
@ -79,6 +81,9 @@ abstract class CheckBadgingTask : DefaultTask() {
@get:InputFile @get:InputFile
abstract val generatedBadging: RegularFileProperty abstract val generatedBadging: RegularFileProperty
@get:Input
abstract val updateBadgingTaskName: Property<String>
override fun getGroup(): String = LifecycleBasePlugin.VERIFICATION_GROUP override fun getGroup(): String = LifecycleBasePlugin.VERIFICATION_GROUP
@TaskAction @TaskAction
@ -91,7 +96,7 @@ abstract class CheckBadgingTask : DefaultTask() {
) { ) {
throw GradleException( throw GradleException(
"Generated badging is different from golden badging! " + "Generated badging is different from golden badging! " +
"If this change is intended, run ./gradlew updateBadging", "If this change is intended, run ./gradlew ${updateBadgingTaskName.get()}",
) )
} }
} }
@ -105,8 +110,9 @@ fun Project.configureBadgingTasks(
componentsExtension.onVariants { variant -> componentsExtension.onVariants { variant ->
// Registers a new task to verify the app bundle. // Registers a new task to verify the app bundle.
val capitalizedVariantName = variant.name.capitalized() val capitalizedVariantName = variant.name.capitalized()
val generateBadgingTaskName = "generate${capitalizedVariantName}Badging"
val generateBadging = val generateBadging =
tasks.register<GenerateBadgingTask>("generate${capitalizedVariantName}Badging") { tasks.register<GenerateBadgingTask>(generateBadgingTaskName) {
apk.set( apk.set(
variant.artifacts.get(SingleArtifact.APK_FROM_BUNDLE), variant.artifacts.get(SingleArtifact.APK_FROM_BUNDLE),
) )
@ -124,7 +130,8 @@ fun Project.configureBadgingTasks(
) )
} }
tasks.register<Copy>("update${capitalizedVariantName}Badging") { val updateBadgingTaskName = "update${capitalizedVariantName}Badging"
tasks.register<Copy>(updateBadgingTaskName) {
from(generateBadging.get().badging) from(generateBadging.get().badging)
into(project.layout.projectDirectory) into(project.layout.projectDirectory)
} }
@ -137,6 +144,7 @@ fun Project.configureBadgingTasks(
generatedBadging.set( generatedBadging.set(
generateBadging.get().badging, generateBadging.get().badging,
) )
this.updateBadgingTaskName.set(updateBadgingTaskName)
output.set( output.set(
project.layout.buildDirectory.dir("intermediates/$checkBadgingTaskName"), project.layout.buildDirectory.dir("intermediates/$checkBadgingTaskName"),

Loading…
Cancel
Save