Convention sourceSetsClassesDirs in ShadowJavaPlugin and ShadowKmpPlugin - #2278
Convention sourceSetsClassesDirs in ShadowJavaPlugin and ShadowKmpPlugin#2278Goooler wants to merge 1 commit into
Conversation
045b4b8 to
e07ef76
Compare
e07ef76 to
950b79e
Compare
There was a problem hiding this comment.
🟡 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.sourceSetsClassesDirsis no longer lazily populated based onminimizeJar; it is now an emptyConfigurableFileCollectionby default.ShadowJavaPluginconventionssourceSetsClassesDirsfrom all JavasourceSetsoutputs (includingtest).ShadowKmpPluginconventionssourceSetsClassesDirsfrom all Kotlin/JVM target compilations outputs (includingtest).
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() |
There was a problem hiding this comment.
You are right! This is a potential breaking change for users who register the task by themselves.
| // 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) } | ||
| ) |
| // 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 } | ||
| } | ||
| ) |
Refs #2276.