From 4f75ab5f89b0923662677ef236bfcedf4083dba1 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 14 Jan 2020 11:42:41 +0000 Subject: [PATCH] Disable generation of Gradle's module metadata The way in which we deploy the artifacts (publishing to a Maven repository on the filesystem and then using the Concourse artifactory resource to upload them) is incompatible with Gradle's module metadata generation. The metadata contains an entry, url, that contains the name of the artifact. This will be something like spring-boot-gradle-plugin-2.3.0.BUILD-20200114.095038-1.jar. The -1 in the name is derived from the Maven snapshot build number. It's -1 as the local repository to which the artifact is published is empty and has no maven-metadata.xml file. When the artifact is uploaded to Artifactory there is a maven-metadata.xml file so the build number is different. As a result, the module metadata points to a file that doesn't exist. This leads to problems like this when trying to consume the snapshots: Could not find spring-boot-gradle-plugin-2.3.0.BUILD-20200114.095038-1-2.3.0.BUILD-SNAPSHOT.jar (org.springframework.boot:spring-boot-gradle-plugin:2.3.0.BUILD-SNAPSHOT:20200114.101952-123) Gradle has used the maven-metadata.xml file on the server to determine that 2.3.0.BUILD-SNAPSHOT:20200114.101952-123 is the latest version. It has downloaded the .module file with this version but it points to spring-boot-gradle-plugin-2.3.0.BUILD-20200114.095038-1.jar. That file doesn't exist so the build fails. See gh-19609 --- .../org/springframework/boot/build/ConventionsPlugin.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java index 30aa02b726..cd8a782286 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java @@ -38,6 +38,7 @@ import org.gradle.api.publish.maven.MavenPomOrganization; import org.gradle.api.publish.maven.MavenPomScm; import org.gradle.api.publish.maven.MavenPublication; import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; +import org.gradle.api.publish.tasks.GenerateModuleMetadata; import org.gradle.api.tasks.bundling.Jar; import org.gradle.api.tasks.compile.JavaCompile; import org.gradle.api.tasks.javadoc.Javadoc; @@ -79,6 +80,8 @@ import org.gradle.api.tasks.testing.Test; * Maven Central's requirements. *
  • If the {@link JavaPlugin Java plugin} has also been applied, creation of Javadoc * and source jars is enabled. + *
  • Generation of Gradle module metadata is disabled as it is incompatible with our + * two-step publishing process.
  • * * *

    @@ -144,6 +147,7 @@ public class ConventionsPlugin implements Plugin { private void applyMavenPublishingConventions(Project project) { project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> { + project.getTasks().withType(GenerateModuleMetadata.class).all((generate) -> generate.setEnabled(false)); PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); if (project.hasProperty("deploymentRepository")) { publishing.getRepositories().maven((mavenRepository) -> {