How to publish multiple module plugin to Gradle Plugin Portal?

My project structure:

+--- Root (empty)
     +--- module1
     +--- module2
     +--- plugin (require module1 and module2)

The userguide(Publishing Plugins to the Gradle Plugin Portal) Only describe how to publish a single plugin module. I don’t know how to publish the moduleN to Gradle Plugin Portal.
And, If I want to use MavenCentral together(I don’t want to use gradle portal only), how to config it? I was tried to use maven-publish plugin together. But the publication that generated by gradle-publish is conflicted.
At last, since the Gradle Plugin Portal is also a Maven repository, can I use the maven-publish directly?

The Gradle Plugin Publish plugin actually already applies the maven-publish plugin for you and configures it, unless you use an ancient version.

So you should not add any custom publications.

Just define the OSSRH repository you want to publish to additionally as publication repository and you should be good.

As you probably need to add some information to the publications to make the OSSRH validation happy, do not create a new publication, but configure the existing publications that were added for you by the Gradle Plugin Publish plugin.

You for example also need to publish the Plugin Marker artifacts, and not only your code artifact.

But how to create the publilcations for other non-plugin project? Just use maven-publish plugin?

Never did that, but probably, yes, just like usual.
I just meant you should not add additional publications for things the Gradle Publish Plugin already added for you like for the plugin code artifact and for the plugin marker artifacts.

1 Like