Skip to content

Commit 8aad9ad

Browse files
jpenillaGoooler
andauthored
Apply legacy plugin last, and declare capabilities for old plugins (#991)
Co-authored-by: Zongle Wang <[email protected]>
1 parent b0842f2 commit 8aad9ad

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,34 @@ tasks.withType<Javadoc>().configureEach {
4545
it.addStringOption("Xdoclint:none", "-quiet")
4646
}
4747
}
48+
49+
configurations {
50+
listOf(
51+
apiElements,
52+
runtimeElements,
53+
named("javadocElements"),
54+
named("sourcesElements"),
55+
).forEach {
56+
it.configure {
57+
outgoing {
58+
// Main/current capability
59+
capability("com.gradleup.shadow:shadow-gradle-plugin:$version")
60+
61+
// Historical capabilities
62+
capability("io.github.goooler.shadow:shadow-gradle-plugin:$version")
63+
capability("com.github.johnrengelman:shadow:$version")
64+
capability("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:$version")
65+
capability("gradle.plugin.com.github.johnrengelman:shadow:$version")
66+
capability("com.github.jengelman.gradle.plugins:shadow:$version")
67+
}
68+
}
69+
}
70+
}
71+
72+
publishing.publications.withType<MavenPublication>().configureEach {
73+
// We don't care about capabilities being unmappable to Maven
74+
suppressPomMetadataWarningsFor("apiElements")
75+
suppressPomMetadataWarningsFor("runtimeElements")
76+
suppressPomMetadataWarningsFor("javadocElements")
77+
suppressPomMetadataWarningsFor("sourcesElements")
78+
}

src/docs/changes/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
## [Unreleased]
55

6+
**Fixed**
7+
8+
- 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))
69

710
## [v8.3.3]
811

src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPlugin.groovy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ class ShadowPlugin implements Plugin<Project> {
1313
void apply(Project project) {
1414
project.with {
1515
plugins.apply(ShadowBasePlugin)
16-
plugins.apply(LegacyShadowPlugin)
1716
plugins.withType(JavaPlugin) {
1817
plugins.apply(ShadowJavaPlugin)
1918
}
2019
plugins.withType(ApplicationPlugin) {
2120
plugins.apply(ShadowApplicationPlugin)
2221
}
22+
// Apply the legacy plugin last
23+
// Because we apply the ShadowJavaPlugin/ShadowApplication plugin in a withType callback for the
24+
// respective JavaPlugin/ApplicationPlugin, it may still apply before the shadowJar task is created and
25+
// etc. if the user applies shadow before those plugins. However, this is fine, because this was also
26+
// the behavior with the old plugin when applying in that order.
27+
plugins.apply(LegacyShadowPlugin)
2328

2429
boolean enableDevelocityIntegration = providers.gradleProperty(
2530
"com.gradleup.shadow.enableDevelocityIntegration"

0 commit comments

Comments
 (0)