gradle-maven-publish-plugin icon indicating copy to clipboard operation
gradle-maven-publish-plugin copied to clipboard

Please provide example gradle

Open orubel opened this issue 10 months ago • 4 comments

looking to publish to maven central nexus repo. Have published in past but recent changes borke my build and their documentation is hirrible.

Looking for gradle example. Can you please provide examples in project?

orubel avatar Feb 05 '25 20:02 orubel

This project uses itself to publish its 3 artifacts, is there anything you want to see in a sample that isn't covered by this?

gabrielittner avatar Feb 06 '25 06:02 gabrielittner

Yeah the artifacts are plugins for gradle. But documentation could use a gradle file as an example to those trying to implement. That way we can see a final exampleof usage.

Would help tremendously :)

The documentation page has snippets of gradle (https://vanniktech.github.io/gradle-maven-publish-plugin/central/#configuring-what-to-publish) but it doesn't show a FINAL VERSIONS of the documentation (or example gradle file)

Maybe an examples directory in root (to avoid any overhead)??

orubel avatar Feb 06 '25 14:02 orubel

Hello. First, a big thanks to this plugin. I recently published a library using the newest version of the plugin. It gives you a vision if you or anyone else have a look at the gradle file. Maybe it helps. https://github.com/shadmanadman/Kmp-WebView/blob/master/composeApp/build.gradle.kts

Also, it is worth mentioning that in my case I had to read and set the gpg keys manually:

val keystorePropertiesFile = rootProject.file("local.properties")
val keystoreProperties = Properties()
keystoreProperties.load(FileInputStream(keystorePropertiesFile))

signing {
    useInMemoryPgpKeys(
        keystoreProperties["signing.keyId"].toString(),
        File(keystoreProperties["signing.secretKeyFile"].toString()).readText(),
        keystoreProperties["signing.password"].toString()
    )
}

Keep themavenCentralUsername and mavenCentralPassword in gradle.properties

shadmanadman avatar Feb 21 '25 09:02 shadmanadman

This project uses itself to publish its 3 artifacts, is there anything you want to see in a sample that isn't covered by this?

As I understand, this project - is the plugin for publishing, and I can use it by adding the import in the build.gradle file: import com.vanniktech.maven.publish.SonatypeHost

But when I try to find out with your documentation https://vanniktech.github.io/gradle-maven-publish-plugin/central/#configuring-what-to-publish I see the first part of the example:

import com.vanniktech.maven.publish.SonatypeHost

mavenPublishing {
  publishToMavenCentral(SonatypeHost.DEFAULT)
  // or when publishing to https://s01.oss.sonatype.org
  publishToMavenCentral(SonatypeHost.S01)
  // or when publishing to https://central.sonatype.com/
  publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

  signAllPublications()
}

And then second:

mavenPublishing {
  coordinates("com.example.mylibrary", "library-name", "1.0.3-SNAPSHOT")

  pom {
...
}

So, the first time I build using the first part, and the second time using the second part? Or do I have to concatenate both?:

import com.vanniktech.maven.publish.SonatypeHost

mavenPublishing {
  publishToMavenCentral(SonatypeHost.DEFAULT)
  // or when publishing to https://s01.oss.sonatype.org
  publishToMavenCentral(SonatypeHost.S01)
  // or when publishing to https://central.sonatype.com/
  publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

  signAllPublications()
  coordinates("com.example.mylibrary", "library-name", "1.0.3-SNAPSHOT")

  pom {
    ...
  }

}

And what do I have to do with a warning?

It’s discouraged to set packaging on the POM, since it can lead to errors or unintended behavior. The value will be automatically set based on the project type if needed.

Does it mean I don't have to use the second part of the example?? (this part has the POM block) How to read and use your documentation properly?

hhlTer avatar Mar 23 '25 17:03 hhlTer