Skip to content

Commit

Permalink
Apply legacy plugin last, and declare capabilities for old plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Sep 29, 2024
1 parent 15a5d53 commit 2432e31
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
36 changes: 36 additions & 0 deletions build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,39 @@ tasks.withType<Javadoc>().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<MavenPublication>().configureEach {
// We don't care about capabilities being unmappable to Maven
suppressPomMetadataWarningsFor("apiElements")
suppressPomMetadataWarningsFor("runtimeElements")
suppressPomMetadataWarningsFor("javadocElements")
suppressPomMetadataWarningsFor("sourcesElements")
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ class ShadowPlugin implements Plugin<Project> {
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') {
Expand Down

0 comments on commit 2432e31

Please sign in to comment.