diff --git a/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts b/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts index fa9f96d8..672cc736 100644 --- a/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts +++ b/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts @@ -45,3 +45,34 @@ tasks.withType().configureEach { it.addStringOption("Xdoclint:none", "-quiet") } } + +configurations { + sequenceOf( + apiElements, + runtimeElements, + named("javadocElements"), + named("sourcesElements"), + ).forEach { + it.configure { + outgoing { + // Main/current capability + capability("com.gradleup.shadow:shadow-gradle-plugin:$version") + + // Historical capabilities + capability("io.github.goooler.shadow:shadow-gradle-plugin:$version") + capability("com.github.johnrengelman:shadow:$version") + capability("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:$version") + capability("gradle.plugin.com.github.johnrengelman:shadow:$version") + capability("com.github.jengelman.gradle.plugins:shadow:$version") + } + } + } +} + +publishing.publications.withType().configureEach { + // We don't care about capabilities being unmappable to Maven + suppressPomMetadataWarningsFor("apiElements") + suppressPomMetadataWarningsFor("runtimeElements") + suppressPomMetadataWarningsFor("javadocElements") + suppressPomMetadataWarningsFor("sourcesElements") +} diff --git a/src/docs/changes/README.md b/src/docs/changes/README.md index 2bb2152c..fa6d8106 100644 --- a/src/docs/changes/README.md +++ b/src/docs/changes/README.md @@ -3,6 +3,7 @@ ## [Unreleased] +- Apply legacy plugin last, and declare capabilities for old plugins, fixes [#964](https://github.com/GradleUp/shadow/issues/964) ([#991](https://github.com/GradleUp/shadow/pull/991)) ## [v8.3.2] diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.groovy index 4b2262f9..c8c0024a 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.groovy +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.groovy @@ -13,13 +13,18 @@ class ShadowPlugin implements Plugin { void apply(Project project) { project.with { plugins.apply(ShadowBasePlugin) - plugins.apply(LegacyShadowPlugin) plugins.withType(JavaPlugin) { plugins.apply(ShadowJavaPlugin) } plugins.withType(ApplicationPlugin) { plugins.apply(ShadowApplicationPlugin) } + // 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 and + // 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) // Legacy build scan support for Gradle Enterprise, users should migrate to develocity plugin. rootProject.plugins.withId('com.gradle.enterprise') {