Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated unit test API access in Gradle Plugin #531

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.takahirom.roborazzi

import com.android.build.api.variant.HasUnitTest
import com.android.build.api.variant.Variant
import com.android.build.gradle.TestedExtension
import org.gradle.api.DefaultTask
Expand Down Expand Up @@ -77,7 +78,7 @@ fun generateComposePreviewRobolectricTestsIfNeeded(
)
project.afterEvaluate {
// We use afterEvaluate only for verify
check(variant.unitTest != null) {
check((variant as? HasUnitTest)?.unitTest != null) {
"Roborazzi: Please enable unit tests for the variant '${variant.name}' in the 'build.gradle' file."
}
verifyTestConfig(testTaskProvider, logger)
Expand Down Expand Up @@ -111,7 +112,7 @@ private fun setupGenerateComposePreviewRobolectricTestsTask(
}
// We need to use sources.java here; otherwise, the generate task will not be executed.
// https://stackoverflow.com/a/76870110/4339442
variant.unitTest?.sources?.java?.addGeneratedSourceDirectory(
(variant as? HasUnitTest)?.unitTest?.sources?.java?.addGeneratedSourceDirectory(
generateTestsTask,
GenerateComposePreviewRobolectricTestsTask::outputDir
)
Expand Down
Loading