Remove _minimizeJar from sourceSetsClassesDirs convention - #2279
Merged
Conversation
`_minimizeJar` is unrelated for `sourceSetsClassesDirs`, and `sourceSetsClassesDirs` is not annotated with `@get:Classpath`. It should be safe to remove the extra flag.
Goooler
force-pushed
the
g/20260903/remove-minimize-flag-from-source-dirs
branch
from
September 3, 2026 10:53
8ea1abd to
fe09586
Compare
_minimizeJar from sourceSetsClassesDirs convention
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
When SourceSetContainer is absent, minimization can silently proceed with empty roots/keep rules and produce incorrect minimized output instead of failing fast.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adjusts how ShadowJar.sourceSetsClassesDirs is convention-initialized so it no longer depends on the _minimizeJar flag, and it becomes resilient to projects that don’t have a Java SourceSetContainer registered.
Changes:
- Replace the
sourceSetsClassesDirsconvention logic to no longer toggle based on_minimizeJar. - Introduce
Project.sourceSetsOrNullto safely accessSourceSetContainerwhen present. - Update
ShadowJarto usesourceSetsOrNullinstead ofsourceSetsfor this convention.
File summaries
| File | Description |
|---|---|
| src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt | Updates sourceSetsClassesDirs convention to use sourceSetsOrNull and removes _minimizeJar gating. |
| src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/GradleCompat.kt | Adds sourceSetsOrNull helper to safely look up SourceSetContainer. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+142
to
146
| project.provider { | ||
| project.sourceSetsOrNull?.map { sourceSet -> | ||
| sourceSet.output.classesDirs.filter(File::isDirectory) | ||
| } ?: emptySet<File>() | ||
| } |
Goooler
added a commit
that referenced
this pull request
Sep 3, 2026
)" This reverts commit cd2cf58.
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.
_minimizeJaris unrelated forsourceSetsClassesDirs, andsourceSetsClassesDirsis not annotated with@get:Classpath. It should be safe to remove the extra flag.Refs #2276.