Use BuildService to fetch adb path instead of caching in a companion object#274
Draft
DanielJette wants to merge 13 commits intomainfrom
Draft
Use BuildService to fetch adb path instead of caching in a companion object#274DanielJette wants to merge 13 commits intomainfrom
DanielJette wants to merge 13 commits intomainfrom
Conversation
https://developer.android.com/build/releases/agp-9-0-0-release-notes 1. In AGP 9.0, the old variants API is removed. The new `androidComponents.onVariants` API is callback-based and `Property` values cannot be accessed during configuration. We now compute applicationTargetPackageId by using `defaultConfig.applicationId`, accounting for `applicationIdSuffix` from build types, and we then use `applicationTargetPackageId` to infer the default test variant ID. (We prefer the debug build type suffix since that's typically what's used for testing.) Note: This doesn't account for flavor-specific `applicationIds` or complex flavor dimension combinations, but users can override by explicitly setting `applicationPackageId` in their `testify` extension. 2. `android.defaultConfig { ... }` takes a lambda with receiver, not a lambda with a parameter, so we can remove `it.resValue` and just call `resValue`. 3. In AGP 9.0, `adb` is accessed via `androidComponents.sdkComponents.adb`, and `sdkComponents` isn't available during configuration time. We now defer resolution until execution time.
We now use `AndroidSourceDirectorySet.directories` instead of the deprecated `AndroidSourceDirectorySet.srcDirs`.
The AGP 9 change made `Project.android` use only `ApplicationExtension`, but the `Samples` also include library modules (e.g. :FlixLibrary, :ComposeExtensions). Those use `LibraryExtension`, so `findByType(ApplicationExtension::class.java)` was null and the plugin threw “Gradle project must contain an android closure” during configuration (e.g. when running ./gradlew dependencies). (Library modules are required to set `applicationPackageId` in their `testify` block, so it's OK that `applicationTargetPackageId` returns null in that case.)
…and path while preserving gradle configuration caching
e77bdf3 to
4e9ad1b
Compare
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.
What does this change accomplish?
How have you achieved it?
Scope of Impact and Testing instructions
Notice
Warning
This change must keep
mainin a shippable state; it may be shipped without further notice.