Skip to content

Remove _minimizeJar from sourceSetsClassesDirs convention - #2279

Merged
Goooler merged 1 commit into
mainfrom
g/20260903/remove-minimize-flag-from-source-dirs
Sep 3, 2026
Merged

Remove _minimizeJar from sourceSetsClassesDirs convention#2279
Goooler merged 1 commit into
mainfrom
g/20260903/remove-minimize-flag-from-source-dirs

Conversation

@Goooler

@Goooler Goooler commented Sep 3, 2026

Copy link
Copy Markdown
Member

_minimizeJar is unrelated for sourceSetsClassesDirs, and sourceSetsClassesDirs is not annotated with @get:Classpath. It should be safe to remove the extra flag.

Refs #2276.

`_minimizeJar` is unrelated for `sourceSetsClassesDirs`, and `sourceSetsClassesDirs` is not annotated with `@get:Classpath`. It should be safe to remove the extra flag.
@Goooler
Goooler force-pushed the g/20260903/remove-minimize-flag-from-source-dirs branch from 8ea1abd to fe09586 Compare September 3, 2026 10:53
@Goooler
Goooler requested a lite review from Copilot September 3, 2026 10:55
@Goooler Goooler changed the title Remove _minimizeJar from sourceSetsClassesDirs convention Remove _minimizeJar from sourceSetsClassesDirs convention Sep 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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 sourceSetsClassesDirs convention logic to no longer toggle based on _minimizeJar.
  • Introduce Project.sourceSetsOrNull to safely access SourceSetContainer when present.
  • Update ShadowJar to use sourceSetsOrNull instead of sourceSets for 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>()
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No need for now.

@Goooler
Goooler merged commit cd2cf58 into main Sep 3, 2026
5 checks passed
@Goooler
Goooler deleted the g/20260903/remove-minimize-flag-from-source-dirs branch September 3, 2026 11:07
Goooler added a commit that referenced this pull request Sep 3, 2026
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.

2 participants