Skip to content

Migrate plugin to the AGP Variant API for AGP 9 support - #365

Draft
FrancoisBlavoet wants to merge 1 commit into
pedrovgs:masterfrom
FrancoisBlavoet:agp-9-support
Draft

Migrate plugin to the AGP Variant API for AGP 9 support#365
FrancoisBlavoet wants to merge 1 commit into
pedrovgs:masterfrom
FrancoisBlavoet:agp-9-support

Conversation

@FrancoisBlavoet

Copy link
Copy Markdown

Summary

AGP 9 removes the legacy variant APIs Shot relies on — AppExtension.applicationVariants, LibraryExtension.libraryVariants, and android.getAdbExe() — so under AGP 9 the plugin registers no ExecuteScreenshotTests tasks and can't resolve adb. This migrates the plugin to the stable androidComponents Variant API:

  • Register screenshot tasks via onVariants for both application and library modules.
  • Wire instrumentation dependencies lazily by task name (onVariants runs before the connected*AndroidTest tasks exist).
  • Resolve adb through AndroidComponentsExtension's SdkComponents.adb provider.
  • shot-android declares its namespace and drops the manifest package attribute (required by AGP 8+/9).
  • Bump compileOnly AGP to 8.2.2 and the Gradle wrapper to 8.5 (AGP 8.2.2 needs Gradle 8.2+).

No visual change — this is a Gradle plugin (Scala/Groovy); no Android UI.

Verification

  • ./gradlew :core:compileScala :shot:compileScala compiles cleanly on the bumped AGP/Gradle.
  • Validated end-to-end in a downstream app on AGP 9.2.1: the per-variant …ExecuteScreenshotTests tasks register and configure (adb + androidTest applicationId resolve).

🤖 Generated with Claude Code

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant