Inject manifest placeholders into test components#107
Open
ojh102 wants to merge 1 commit into
Open
Conversation
8c866af to
0160eba
Compare
The plugin injects manifest placeholders only into the main variant. Test
manifests (unit test and android test) are merged from the same sources and
reference the same placeholders (e.g. ${MAPS_API_KEY}), but never receive a
value. With recent AGP versions that validate the test manifest merge, the
build fails with:
Attribute meta-data#...@value requires a placeholder substitution but no
value for <MAPS_API_KEY> is provided.
Fixes the long-standing report in google#41.
Changes:
- Add `TestComponent.inject` that applies only manifest placeholders (test
components do not generate a BuildConfig). This covers both UnitTest and
AndroidTest, which are the variant's nested TestComponents.
- After injecting the main variant, also inject its nested test components.
- Bump the compiled-against AGP from 7.0.4 to 7.4.0 — the first version where
`TestComponent.manifestPlaceholders` exists — kept as low as possible to
preserve compatibility for consumers still on AGP 7.x.
- Add a unit test covering test-component placeholder injection.
0160eba to
fbe4bca
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.
Fixes #41.
Problem
The plugin injects manifest placeholders only into the main variant. Both unit-test and android-test manifests are merged from the same sources and reference the same placeholders (e.g.
${MAPS_API_KEY}), but they never receive a value.This was harmless until AGP started validating the test manifest merge. On recent AGP versions
processDebugUnitTestManifest(and the equivalent android-test task) fails the build:The main/release build works fine — only test variants break. This is the same
<MAPS_API_KEY> not providedfailure reported in #41 (theTry to repro #41branch confirms it reproduces).Isolation
Triggered purely by the AGP version, everything else held constant:
processDebugUnitTestManifest<MAPS_API_KEY> not provided)Fix
After injecting the main variant, also inject manifest placeholders into its nested test components:
TestComponent.injectapplying only manifest placeholders (test components don't generate aBuildConfig, so unlikeVariant.injectit skipsbuildConfigFields). Since both UnitTest and AndroidTest are the variant's nestedTestComponents, iteratingnestedComponentscovers both.SecretsPlugin, inject the nested test components alongside the main variant for every property source (defaults, properties, build-type, flavor).7.0.4 → 7.4.0— the first version whereTestComponent.manifestPlaceholdersexists — kept as low as possible to preserve compatibility for consumers still on AGP 7.x. (The sample app and tests keep building against 8.4.2 to exercise the fix on newer AGP.)Test
Added
test component receives manifest placeholders, verifying injection and ignore-list handling. The plugin compiles against AGP 7.4.0; the sample app and tests run against 8.4.2. All existing tests pass.