Skip to content

Convention sourceSetsClassesDirs in ShadowJavaPlugin and ShadowKmpPlugin - #2278

Closed
Goooler wants to merge 1 commit into
mainfrom
g/20260903/init-sources-dirs-for-each
Closed

Convention sourceSetsClassesDirs in ShadowJavaPlugin and ShadowKmpPlugin#2278
Goooler wants to merge 1 commit into
mainfrom
g/20260903/init-sources-dirs-for-each

Conversation

@Goooler

@Goooler Goooler commented Sep 3, 2026

Copy link
Copy Markdown
Member

Refs #2276.

@Goooler
Goooler force-pushed the g/20260903/init-sources-dirs-for-each branch from 045b4b8 to e07ef76 Compare September 3, 2026 10:31
@Goooler
Goooler requested a lite review from Copilot September 3, 2026 10:33
@Goooler
Goooler force-pushed the g/20260903/init-sources-dirs-for-each branch from e07ef76 to 950b79e Compare September 3, 2026 10:37

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

The new conventions are applied unconditionally (adding avoidable inputs/dependencies when minimization is off) and the task default becoming empty can silently break minimization for custom ShadowJar tasks.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR shifts responsibility for setting ShadowJar.sourceSetsClassesDirs from the ShadowJar task itself to the plugins (ShadowJavaPlugin and ShadowKmpPlugin), with the intent of standardizing how minimization roots are derived (including test outputs).

Changes:

  • ShadowJar.sourceSetsClassesDirs is no longer lazily populated based on minimizeJar; it is now an empty ConfigurableFileCollection by default.
  • ShadowJavaPlugin conventions sourceSetsClassesDirs from all Java sourceSets outputs (including test).
  • ShadowKmpPlugin conventions sourceSetsClassesDirs from all Kotlin/JVM target compilations outputs (including test).
File summaries
File Description
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt Removes built-in lazy default population for sourceSetsClassesDirs.
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowKmpPlugin.kt Adds plugin-side convention for sourceSetsClassesDirs from KMP compilations.
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.kt Adds plugin-side convention for sourceSetsClassesDirs from Java source sets.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

}
}
}
public open val sourceSetsClassesDirs: ConfigurableFileCollection = objectFactory.fileCollection()

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.

You are right! This is a potential breaking change for users who register the task by themselves.

Comment on lines +46 to +50
// Include all source sets (including test) so that test code's transitive dependency
// references are also considered "used" during minimization.
task.sourceSetsClassesDirs.convention(
sourceSets.map { it.output.classesDirs.filter(File::isDirectory) }
)
Comment on lines +44 to +50
// Include all compilations (including test) so that test code's transitive dependency
// references are also considered "used" during minimization.
task.sourceSetsClassesDirs.convention(
target.compilations.map { compilation ->
compilation.output.classesDirs.filter { it.isDirectory }
}
)
@Goooler

Goooler commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

#2279

@Goooler Goooler closed this Sep 3, 2026
@Goooler
Goooler deleted the g/20260903/init-sources-dirs-for-each branch September 3, 2026 10:54
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