Migrate plugin to the AGP Variant API for AGP 9 support - #365
Draft
FrancoisBlavoet wants to merge 1 commit into
Draft
Migrate plugin to the AGP Variant API for AGP 9 support#365FrancoisBlavoet wants to merge 1 commit into
FrancoisBlavoet wants to merge 1 commit into
Conversation
AGP 9 removes the legacy variant APIs the plugin depended on: AppExtension.applicationVariants, LibraryExtension.libraryVariants, and android.getAdbExe(). Without them the plugin registered no ExecuteScreenshotTests tasks and could not resolve adb under AGP 9. - ShotPlugin: register screenshot tasks via androidComponents.onVariants for both application and library modules; wire instrumentation dependencies lazily by task name (onVariants runs before the connected*AndroidTest tasks exist). - AdbPathExtractor: resolve adb through AndroidComponentsExtension's SdkComponents.adb provider instead of android.getAdbExe(). - Tasks: derive task names from the variant build-type name string rather than the removed BuildType model. - shot-android: declare the namespace in build.gradle and drop the package attribute from AndroidManifest (required by AGP 8+/9). - Bump compileOnly AGP to 8.2.2 and the Gradle wrapper to 8.5 (AGP 8.2.2 requires Gradle 8.2+), and make compileScala depend on compileGroovy so AdbPathExtractor is on the Scala compile classpath.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AGP 9 removes the legacy variant APIs Shot relies on —
AppExtension.applicationVariants,LibraryExtension.libraryVariants, andandroid.getAdbExe()— so under AGP 9 the plugin registers noExecuteScreenshotTeststasks and can't resolveadb. This migrates the plugin to the stableandroidComponentsVariant API:onVariantsfor both application and library modules.onVariantsruns before theconnected*AndroidTesttasks exist).adbthroughAndroidComponentsExtension'sSdkComponents.adbprovider.shot-androiddeclares itsnamespaceand drops the manifestpackageattribute (required by AGP 8+/9).No visual change — this is a Gradle plugin (Scala/Groovy); no Android UI.
Verification
./gradlew :core:compileScala :shot:compileScalacompiles cleanly on the bumped AGP/Gradle.…ExecuteScreenshotTeststasks register and configure (adb + androidTest applicationId resolve).🤖 Generated with Claude Code