Im-Fran / SonatypeCentralUpload

A gradle plugin to upload artifacts to Sonatype Central
https://plugins.gradle.org/plugin/cl.franciscosolis.sonatype-central-upload
GNU General Public License v3.0
9 stars 2 forks source link

Add publishingType option #2

Closed eriksencosta closed 3 months ago

eriksencosta commented 3 months ago

The plugin, by default, publishes the jar to Central once it is validated. However, some library maintainers may want to publish it manually, as Maven has a policy of never deleting a jar once it's published.

This pull request introduces a new option to sonatypeCentralUpload task: publishingType. To prevent breaking previous users of the plugin, the option may be omitted. If omitted, it will continue behaving as the plugin behaves currently: it will publish the jar once it's validated:

sonatypeCentralUpload {
    username = "your-username"
    password = "your-password"

    archives = files(/*...*/)
    pom = file("path/to/pom.xml")

    signingKey = "--BEGIN PGP PRIVATE KEY BLOCK--"
    signingKeyPassphrase = "..."
    publicKey = "--BEGIN PGP PUBLIC KEY BLOCK--"

    publishingType = "MANUAL"
}

I've tested the plugin using Maven local. However, as I'm not the owner of the cl.franciscosolis on Central, my test always fails as initPublishingProcess throws an IllegalStateException when deploymentStatus returns FAILED.

Im-Fran commented 3 months ago

It's a great idea, thanks for the contribution!

eriksencosta commented 3 months ago

@Im-Fran I forgot to add, but I found that the syntax to set the plugin changed since v1.0.0, from:

sonatypeCentralUpload {
  // setup code
}

To:

tasks.named<SonatypeCentralUploadTask>("sonatypeCentralUpload") {
  // setup code
}

I can't make the former work.

Im-Fran commented 3 months ago

@eriksencosta you have to use it inside the tasks tag, like this:

tasks {
    sonatypeCentralUpload {
        // ....
    }
}