Hey folks, I’m having some trouble generating a `m...
# plugin-development
r
Hey folks, I’m having some trouble generating a
maven-metadata.xml
file for a plugin I’m publishing. Here’s the situation: I currently publish this gradle plugin to
mavenRepo1
. I’m curious about a new repository, so I’d like to also publish to
mavenRepo2
. When I attempt to publish, I get a 404 error that
maven-metadata.xml
cannot be found when publishing to
mavenRepo2
. When I look in
/build/tmp/publishPluginNameMarkerMavenPublicationToMavenRepo2Repository
, there’s no
mave-metadata.xml
, but the same folder for
mavenRepo1
. I’m having this issue with both snapshot and release publishing. I’m not using any custom config for this file, and I’m not sure why it’s not being created for the new repository. Does anyone have any insight here? Here’s my
publishing
block in the plugin’s
build.gradle
file:
Copy code
publishing {
    repositories {
        maven {
            name = 'mavenRepo1'
            credentials {
                username = '<username>'
                password = '<password>'
            }
            afterEvaluate {
                url = version.endsWith('SNAPSHOT')
                        ? '<snapshot-repo-url>'
                        : '<release-repo-url>'
            }
        }
        maven {
            name = 'mavenRepo2'
            credentials {
                username = '<username>'
                password = '<password>'
            }
            afterEvaluate {
                url = version.endsWith('SNAPSHOT')
                        ? '<snapshot-repo-url>'
                        : '<release-repo-url>'
            }
        }
    }
}
v
Usually, you should not need to do anything for this. It should automatically be created and published by the
AbstractMavenPublisher
unless you got some exception. Maybe you want to set a breakpoint there and check what is happening.
r
Yeah, I didn’t get an exception, but I did see this task was being skipped, and I can’t seem to figure out why:
Copy code
> Task :generateMetadataFileForpluginNamePluginMarkerMavenPublication SKIPPED
Maven publication 'pluginNamePluginMarkerMaven' isn't attached to a component. Gradle metadata only supports publications with software components (e.g. from component.java)
Skipping task ':generateMetadataFileForPluginNamePluginMarkerMavenPublication' as task onlyIf 'The publication is attached to a component' is false.
i have another plugin wih a nearly identical
build.gradle
file, the only difference is the plugin name and some dependencies, and it doesn’t have this issue.
v
That task has nothing to do with your question
That task would generate the Gradle Module Metadata file
But as the marker artifact is just a type pom one that refers to the code artifact, it does not get Gradle Module Metadata
Hence it is skipped and that is what the message told you
The
module-maven-metadata.xml
is generated by the
AbstractMavenPublisher
on the fly while publishing