diff --git a/buildSrc/src/main/java/org/springframework/gradle/maven/PublishAllJavaComponentsPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/maven/PublishAllJavaComponentsPlugin.java index 4bbf23932f..408d83e716 100644 --- a/buildSrc/src/main/java/org/springframework/gradle/maven/PublishAllJavaComponentsPlugin.java +++ b/buildSrc/src/main/java/org/springframework/gradle/maven/PublishAllJavaComponentsPlugin.java @@ -5,7 +5,10 @@ import org.gradle.api.Action; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.plugins.JavaPlatformPlugin; +import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.publish.PublishingExtension; +import org.gradle.api.publish.VariantVersionMappingStrategy; +import org.gradle.api.publish.VersionMappingStrategy; import org.gradle.api.publish.maven.MavenPublication; import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; @@ -14,13 +17,15 @@ public class PublishAllJavaComponentsPlugin implements Plugin { public void apply(Project project) { project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> { PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); - publishing.getPublications().create("maven", MavenPublication.class, new Action() { + publishing.getPublications().create("mavenJava", MavenPublication.class, new Action() { @Override public void execute(MavenPublication maven) { - project.getPlugins().withType(JavaPlatformPlugin.class) - .all((javaPlugin) -> project.getComponents() - .matching((component) -> component.getName().equals("javaPlatform")) - .all((javaComponent) -> maven.from(javaComponent))); + project.getPlugins().withType(JavaPlugin.class, (plugin) -> { + maven.from(project.getComponents().getByName("java")); + }); + project.getPlugins().withType(JavaPlatformPlugin.class, (plugin) -> { + maven.from(project.getComponents().getByName("javaPlatform")); + }); } }); });