Skip to content

Commit

Permalink
Simplify ShadowPlugin.apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Jan 29, 2025
1 parent 5054fbf commit 3f89708
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import org.gradle.api.plugins.JavaPlugin
public abstract class ShadowPlugin : Plugin<Project> {

override fun apply(project: Project) {
project.run {
plugins.apply(ShadowBasePlugin::class.java)
with(project.plugins) {
apply(ShadowBasePlugin::class.java)
@Suppress("WithTypeWithoutConfigureEach")
plugins.withType(JavaPlugin::class.java) {
plugins.apply(ShadowJavaPlugin::class.java)
withType(JavaPlugin::class.java) {
apply(ShadowJavaPlugin::class.java)
}
@Suppress("WithTypeWithoutConfigureEach")
plugins.withType(ApplicationPlugin::class.java) {
plugins.apply(ShadowApplicationPlugin::class.java)
withType(ApplicationPlugin::class.java) {
apply(ShadowApplicationPlugin::class.java)
}
// Apply the legacy plugin last
// Because we apply the ShadowJavaPlugin/ShadowApplication plugin in a withType callback for the
// respective JavaPlugin/ApplicationPlugin, it may still apply before the shadowJar task is created etc.
// If the user applies shadow before those plugins. However, this is fine, because this was also
// the behavior with the old plugin when applying in that order.
plugins.apply(LegacyShadowPlugin::class.java)
apply(LegacyShadowPlugin::class.java)
}
}
}

0 comments on commit 3f89708

Please sign in to comment.