Skip to content

Conversation

Jonathing
Copy link
Contributor

@Jonathing Jonathing commented Sep 20, 2025

Adds a new property to the ShadowJar task that dictates the bundling type to be used for the consumable configuration. I'm adding the bundling attribute using AttributeContainer#attributeProvider as lazily-added attribute aren't computed until they're needed, which is after project evaluation.

Once again looking for help with tests and code cleanup like last time. Kotlin is not my primary language 😅


tasks.shadowJar {
  bundlingAttribute = 'embedded'
}

  • CHANGELOG's "Unreleased" section has been updated, if applicable.

@Jonathing

This comment was marked as resolved.

@Jonathing Jonathing marked this pull request as draft September 20, 2025 16:43
@Jonathing Jonathing marked this pull request as ready for review September 20, 2025 16:52
@Jonathing Jonathing force-pushed the feat/jonathing/bundling-embedded-attribute branch from 74ea7a2 to d50fb88 Compare September 20, 2025 17:23
@Jonathing
Copy link
Contributor Author

After thinking on your comments, I went ahead with a different approach, one that defaults to Bundling.SHADOWED and is completely dependent on the task itself rather than the shadow extension. Let me know if you got more comments or suggestions.

@Jonathing Jonathing requested a review from Goooler September 20, 2025 17:24
```kotlin
tasks.shadow {
  // Unsetting automatically uses `Bundling.EMBEDDED` attribute if and only if there is no relocation.
  bundlingAttribute = null

  // Setting manually forces that attribute to be used instead.
  bundlingAttribute = 'embedded'
}
```
@Jonathing Jonathing force-pushed the feat/jonathing/bundling-embedded-attribute branch from 8299e1e to 167e94b Compare September 20, 2025 17:49
@Goooler
Copy link
Member

Goooler commented Sep 21, 2025

Once again looking for help with tests and code cleanup like last time. Kotlin is not my primary language 😅

You can add a new test ref the others in

Also needs an extra check in

Co-authored-by: Zongle Wang <wangzongler@gmail.com>
@Goooler Goooler changed the title Allow using Bundling.EMBEDDED for non-relocating shadow JARs Allow overriding BUNDLING_ATTRIBUTE in GMM Sep 24, 2025
@Goooler Goooler requested a review from Copilot September 24, 2025 06:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for overriding the BUNDLING_ATTRIBUTE in Gradle Module Metadata (GMM) for shadow JARs through a new bundlingAttribute property in the ShadowExtension.

  • Introduces a new bundlingAttribute property in ShadowExtension with default value Bundling.SHADOWED
  • Updates the attribute setting logic to use attributeProvider with lazy evaluation
  • Adds comprehensive tests and documentation for the new feature

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowExtension.kt Adds the new bundlingAttribute property definition
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowBasePlugin.kt Sets the default convention value for the bundling attribute
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.kt Updates attribute configuration to use the new property with lazy evaluation
src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowPropertiesTest.kt Adds test assertion for the default bundling attribute value
src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/PublishingTest.kt Adds functional test for overriding the bundling attribute
docs/publishing/README.md Documents the new feature with usage examples
docs/changes/README.md Updates changelog with the new feature
api/shadow.api Updates public API surface with new method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Goooler Goooler requested a review from Copilot September 24, 2025 06:36
Copilot

This comment was marked as outdated.

@Goooler Goooler force-pushed the feat/jonathing/bundling-embedded-attribute branch from 33e682c to 3d71dc5 Compare September 24, 2025 06:43
@Goooler Goooler force-pushed the feat/jonathing/bundling-embedded-attribute branch from 3d71dc5 to 6b1d10e Compare September 24, 2025 06:44
@Goooler Goooler requested a review from Copilot September 24, 2025 06:45
Copilot

This comment was marked as outdated.

@Goooler Goooler enabled auto-merge (squash) September 24, 2025 06:49
@Goooler Goooler merged commit b613233 into GradleUp:main Sep 24, 2025
9 checks passed
@Jonathing
Copy link
Contributor Author

Thanks for finishing this up for me. I ended up having a busy start to my week.

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.

Non-relocating shadow jars should use Bundling.EMBEDDED
2 participants