[Feedback needed] Gradle Module Metadata


(Cédric Champeau) #1

Hi folks,

I’m starting this thread to gather feedback about Gradle Module Metadata, which ships 1.0 in Gradle 5.3.

We’re looking for early adopters, both on the library authors side (you build a library, and you’d like to publish Gradle Module Metadata) and as a consumer of module metadata.

Feel free to ask questions here, this thread might be split into specific discussions as needed.

Thanks a lot!


(Ingmar Steiner) #2

Looks like a very nice feature that would also help with managing elaborate custom details about published artifacts at the dependency management level!

However, I’m afraid I need a leg up on how to try this out. In a data project, I did this:

  1. I upgrade my Gradle wrapper to 5.3-rc-3
  2. I appended enableFeaturePreview("GRADLE_METADATA") to my settings.gradle
  3. I ran ./gradlew publish, but could not find any *.module files in the target repository

Inspecting this further, I ran ./gradlew generatePomFileForMavenPublication and see this output:

> Task :generateMetadataFileForMavenPublication SKIPPED
Maven publication 'maven' isn't attached to a component. Gradle metadata only supports publications with software components (e.g. from component.java)

My project only uses the ‘base’ and ‘maven-publish’ plugins, and the ‘default’ artifact is just a Zip task:

task packageRefPitch(type: Zip) {
    from extractData.refDir
    classifier 'reference'
}

artifacts {
    'default' packageRefPitch
}

publishing {
    publications {
        maven(MavenPublication) {
            artifact packageRefPitch
        }
    }
    repositories {
        maven {
            url "$buildDir/repo"
        }
    }
}

How can I publish a Gradle .module file with some custom metadata? If that doesn’t work directly, how can I register the ‘default’ artifact of my data project as a component?


(Cédric Champeau) #3

The error message says it all:

Maven publication 'maven' isn't attached to a component. Gradle metadata only supports publications with software components (e.g. from component.java)

You must have a software component, so that Gradle understands the semantics of your module (that’s what Gradle Module Metadata is about). So you need something like:

from components.java

adhoc artifacts are by definition out of context :slight_smile:


(Ingmar Steiner) #4

Is it planned to support ad-hoc artifacts? Or do I have to find a way to register my custom artifact as a component? (I tried that some time ago, but gave up without finding a solution. Any pointers would be much appreciated!)


(Cédric Champeau) #5

The whole idea is that there are no adhoc artifacts. Artifacts are attached to variants. And yes there’s an API for that, using SoftwareComponentFactory. The Java plugins uses this API to declare custom components.


(Ingmar Steiner) #6

Thanks very much for the prompt and helpful replies! I’ll see what I can come with and open a different discussion if necessary.