Allow repackaging Service file classes with R8 - #2174
Merged
Conversation
Goooler
force-pushed
the
g/20260810/allowrepackage-for-service-files
branch
from
August 10, 2026 08:42
1ac38e0 to
95d438a
Compare
Goooler
force-pushed
the
g/20260810/allowrepackage-for-service-files
branch
from
August 10, 2026 08:51
95d438a to
22f9ddc
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR follows up on prior R8 relocation documentation work by adjusting Shadow’s generated R8 keep rules so that classes referenced from META-INF/services/** can still be repackaged when -repackageclasses is used, while keeping ServiceLoader wiring intact.
Changes:
- Update R8 minimizer service keep rules to permit repackaging of service interfaces/providers.
- Simplify and tighten functional tests around service file relocation and R8 repackaging behavior.
- Add a CHANGELOG entry for the new behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/R8Minimizer.kt | Adjusts generated ProGuard/R8 rules for service descriptor classes/providers during minimization. |
| src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformerTest.kt | Updates functional tests to validate relocated service entries and R8 repackaging results. |
| docs/changes/README.md | Documents the change in the Unreleased changelog section. |
Suppressed comments (1)
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/R8Minimizer.kt:217
- Same issue here:
allowrepackageshould beallowrepackagingto correctly permit R8 repackaging while still keeping the service provider class.
.forEach { provider -> rules += "-keep,allowrepackage class $provider { *; }" }
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Follow up #2173 (comment).