Skip to content

Comments

Use BuildService to fetch adb path instead of caching in a companion object#274

Open
DanielJette wants to merge 5 commits intomainfrom
adb-service
Open

Use BuildService to fetch adb path instead of caching in a companion object#274
DanielJette wants to merge 5 commits intomainfrom
adb-service

Conversation

@DanielJette
Copy link
Contributor

@DanielJette DanielJette commented Feb 17, 2026

What does this change accomplish?

This change refactors the way ADB is initialized and managed within the Testify Gradle plugin. It introduces a Gradle Build Service to handle ADB-related properties, aiming to improve build performance, support build caching, and enhance compatibility with Gradle's configuration avoidance.

How have you achieved it?

A new AdbService class has been introduced as a Gradle BuildService. This service is responsible for providing the ADB executable path, verbosity settings, forced user, and device target index to other components of the plugin.

The Adb class has been refactored to remove its static init() method and now takes an instance of AdbService in its constructor. This dependency injection ensures that Adb instances consistently use the properties provided by the BuildService.

All relevant Testify Gradle tasks (e.g., ScreenshotClearTask, ScreenshotPullTask, ScreenshotTestTask, DeviceKeyTask, DevicesTask, LocaleTask, TimeZoneTask) and internal utility functions (Device, DeviceUtilities) have been updated to obtain and utilize the AdbService via their respective TestifyDefaultTask superclass. This ensures that all ADB interactions leverage the new service-based approach.

The unit tests for AdbTest have been updated to reflect and verify the new AdbService injection mechanism.

Scope of Impact and Testing instructions

This is a significant internal refactoring of the Testify Gradle plugin's core ADB interaction layer. While the public API and task behaviors are intended to remain unchanged, the underlying implementation has been substantially altered.

Impact:

  • Improved compatibility with Gradle's build caching and configuration avoidance.
  • More robust and consistent management of ADB properties across tasks.
  • No expected breaking changes for end-users of the Testify plugin.

Testing Instructions:

  1. Ensure all existing unit tests for the Gradle plugin pass (./gradlew :Plugin:test).
  2. Verify the functionality of key screenshot testing tasks:
    • ./gradlew FlixSample:screenshotRecord (to record baselines)
    • ./gradlew FlixSample:screenshotTest (to compare screenshots against baselines)
    • ./gradlew FlixSample:screenshotPull (to pull failed screenshots)
    • ./gradlew FlixSample:screenshotClear (to clear failed screenshots)
  3. Confirm that utility tasks such as ./gradlew FlixSample:testifyDeviceKey, ./gradlew FlixSample:testifyDevices, ./gradlew FlixSample:testifyLocale, ./gradlew FlixSample:testifyTimeZone function correctly and display the expected information.
  4. Test the plugin with different Android SDK versions and device configurations to ensure AdbService correctly retrieves the ADB path and device information.

Notice

Warning

This change must keep main in a shippable state; it may be shipped without further notice.

@DanielJette DanielJette marked this pull request as ready for review February 21, 2026 19:52
@DanielJette DanielJette requested a review from a team February 21, 2026 19:53
@DanielJette
Copy link
Contributor Author

cc @dfabulich

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.

2 participants