From 834a1fca0d4f0e8dceff7d82ff430283c5c01f29 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Mon, 17 May 2021 17:50:02 -0500 Subject: [PATCH] versionMapping --- .../maven/MavenPublishingConventionsPlugin.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/java/org/springframework/gradle/maven/MavenPublishingConventionsPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/maven/MavenPublishingConventionsPlugin.java index d82b6d9436..b799095f40 100644 --- a/buildSrc/src/main/java/org/springframework/gradle/maven/MavenPublishingConventionsPlugin.java +++ b/buildSrc/src/main/java/org/springframework/gradle/maven/MavenPublishingConventionsPlugin.java @@ -6,6 +6,8 @@ import org.gradle.api.Project; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPluginExtension; import org.gradle.api.publish.PublishingExtension; +import org.gradle.api.publish.VariantVersionMappingStrategy; +import org.gradle.api.publish.VersionMappingStrategy; import org.gradle.api.publish.maven.MavenPom; import org.gradle.api.publish.maven.MavenPomDeveloperSpec; import org.gradle.api.publish.maven.MavenPomIssueManagement; @@ -23,7 +25,20 @@ public class MavenPublishingConventionsPlugin implements Plugin { public void execute(MavenPublishPlugin mavenPublish) { PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); publishing.getPublications().withType(MavenPublication.class) - .all((mavenPublication) -> MavenPublishingConventionsPlugin.this.customizePom(mavenPublication.getPom(), project)); + .all((mavenPublication) -> { + mavenPublication.versionMapping(new Action() { + @Override + public void execute(VersionMappingStrategy versionStrategy) { + versionStrategy.usage("java-runtime", new Action() { + @Override + public void execute(VariantVersionMappingStrategy mappingStrategy) { + mappingStrategy.fromResolutionResult(); + } + }); + } + }); + MavenPublishingConventionsPlugin.this.customizePom(mavenPublication.getPom(), project); + }); MavenPublishingConventionsPlugin.this.customizeJavaPlugin(project); } });