From 2432e31d124d9427b6710ddced4b5264658e3633 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:08:01 -0700 Subject: [PATCH 1/5] Apply legacy plugin last, and declare capabilities for old plugins fixes #964 --- .../shadow.convention.publish.gradle.kts | 36 +++++++++++++++++++ .../gradle/plugins/shadow/ShadowPlugin.groovy | 7 +++- 2 files changed, 42 insertions(+), 1 deletion(-) 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 fa9f96d82..082f5cdef 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,39 @@ tasks.withType().configureEach { it.addStringOption("Xdoclint:none", "-quiet") } } + +configurations { + sequenceOf( + apiElements, + runtimeElements, + named("javadocElements"), + named("sourcesElements"), + ).forEach { + it.configure { + attributes { + // We have dependencies that require Java 11 (jdependency) + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 11) + } + + 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/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.groovy index 4b2262f97..c8c0024ac 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') { From afa91da20b39a93401334d69d7b7fd282e7eda4f Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:11:50 -0700 Subject: [PATCH 2/5] Update changelog --- src/docs/changes/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/docs/changes/README.md b/src/docs/changes/README.md index 2bb2152c9..a8d827735 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/pull/964) ([#991](https://github.com/GradleUp/shadow/pull/991)) ## [v8.3.2] From 6de8a80c6a90f35bdcb2453822bb586851128131 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:16:02 -0700 Subject: [PATCH 3/5] remove change unrelated to linked issue --- .../src/main/kotlin/shadow.convention.publish.gradle.kts | 5 ----- 1 file changed, 5 deletions(-) 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 082f5cdef..672cc7361 100644 --- a/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts +++ b/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts @@ -54,11 +54,6 @@ configurations { named("sourcesElements"), ).forEach { it.configure { - attributes { - // We have dependencies that require Java 11 (jdependency) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 11) - } - outgoing { // Main/current capability capability("com.gradleup.shadow:shadow-gradle-plugin:$version") From 3f2a7c009108e3c713e4be4ba589c555f8441a73 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:35:33 -0700 Subject: [PATCH 4/5] Adjust changelog link The previous link worked but this is more correct --- src/docs/changes/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/changes/README.md b/src/docs/changes/README.md index a8d827735..fa6d8106e 100644 --- a/src/docs/changes/README.md +++ b/src/docs/changes/README.md @@ -3,7 +3,7 @@ ## [Unreleased] -- Apply legacy plugin last, and declare capabilities for old plugins, fixes [#964](https://github.com/GradleUp/shadow/pull/964) ([#991](https://github.com/GradleUp/shadow/pull/991)) +- 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] From cd4594db46283634f18caf6311bd1b55c0526e19 Mon Sep 17 00:00:00 2001 From: Zongle Wang Date: Thu, 24 Oct 2024 16:30:20 +0800 Subject: [PATCH 5/5] Apply suggestions from code review --- .../src/main/kotlin/shadow.convention.publish.gradle.kts | 2 +- src/docs/changes/README.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 672cc7361..6282e8c30 100644 --- a/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts +++ b/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts @@ -47,7 +47,7 @@ tasks.withType().configureEach { } configurations { - sequenceOf( + listOf( apiElements, runtimeElements, named("javadocElements"), diff --git a/src/docs/changes/README.md b/src/docs/changes/README.md index fa6d8106e..62c1ac3ec 100644 --- a/src/docs/changes/README.md +++ b/src/docs/changes/README.md @@ -3,7 +3,9 @@ ## [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)) +**Fixed** + +- 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]