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
pull/19711/head
Andy Wilkinson 5 years ago
parent 246f5ce8eb
commit 4f75ab5f89

@ -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.
* <li>If the {@link JavaPlugin Java plugin} has also been applied, creation of Javadoc
* and source jars is enabled.
* <li>Generation of Gradle module metadata is disabled as it is incompatible with our
* two-step publishing process.</li>
* </ul>
*
* <p/>
@ -144,6 +147,7 @@ public class ConventionsPlugin implements Plugin<Project> {
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) -> {

Loading…
Cancel
Save