Repository navigation
Conversation
Use `attributeProvider` for `org.gradle.jvm.version` of `shadowRuntimeElements` so the JVM version is not read eagerly (#2086) and the configuration is not mutated after it may have been locked by other plugins (#2054). `attributeProvider` must always provide a value, so the attribute is always added now: setting `addTargetJvmVersionAttribute` to `false` or calling `java.disableAutoTargetJvm()` makes it fall back to `java.targetCompatibility`.
afterEvaluate
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The existing fallback tests do not cover early locking of shadowRuntimeElements, so a functional regression test is needed to catch late attribute mutation and verify published JVM-version metadata.
1 open issue
What changed in this PR
This PR makes the shadowed variant’s target JVM attribute lazy, addressing eager toolchain finalization (#2086) and late configuration mutation (#2054).
Changes:
- Uses
attributeProviderinstead ofafterEvaluateto supply the JVM version. - Always includes the attribute, falling back to
java.targetCompatibilitywhen inference is disabled or unavailable. - Updates publishing tests and documentation for the changed opt-out behavior.
| File | Description |
|---|---|
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.kt |
Registers the JVM attribute lazily and removes late mutation. |
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowExtension.kt |
Documents inference and fallback behavior. |
src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/PublishingTest.kt |
Updates assertions for fallback JVM metadata. |
docs/publishing/README.md |
Explains the revised attribute configuration behavior. |
CHANGELOG.md |
Records the lifecycle fixes and potentially breaking behavior. |
Review effort: Balanced
Comment on lines
+92
to
+94
| attrs.attributeProvider( | ||
| TARGET_JVM_VERSION_ATTRIBUTE, | ||
| provider { |
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.

Use
attributeProviderfororg.gradle.jvm.versionofshadowRuntimeElementsso the JVM version is not read eagerly (#2086) and the configuration is not mutated after it may have been locked by other plugins (#2054).attributeProvidermust always provide a value, so the attribute is always added now: settingaddTargetJvmVersionAttributetofalseor callingjava.disableAutoTargetJvm()makes it fall back tojava.targetCompatibility.