Sonatype Central
This plugin allows users to publish open-source packages to Maven Central via the Sonatype Central portal.
Quickstart
Add the following to your build.mill
:
package build
import $ivy.`com.lihaoyi::mill-contrib-sonatypecentral:`
import mill.contrib.sonatypecentral.SonatypeCentralPublishModule
object mymodule extends SonatypeCentralPublishModule {
...
}
Then run the following to publish the individual module:
$ mill mymodule.publishSonatypeCentral
To publish several modules at once, run the following, with arguments adjusted for your use case:
$ mill -i \ mill.contrib.sonatypecentral.SonatypeCentralPublishModule/publishAll \ --username myusername \ --password mypassword \ --gpgArgs --passphrase=$GPG_PASSPHRASE,--no-tty,--pinentry-mode,loopback,--batch,--yes,-a,-b \ --publishArtifacts __.publishArtifacts \ --readTimeout 36000 \ --awaitTimeout 36000 \ --connectTimeout 36000 \ --shouldRelease false \ --bundleName com.lihaoyi-requests:1.0.0
Module Settings
Below are the default publishing settings on the module level, which can be explicitly configured by users like so:
object mymodule extends SonatypeCentralPublishModule {
override def sonatypeCentralGpgArgs: T[String] = "--batch, --yes, -a, -b"
override def sonatypeCentralConnectTimeout: T[Int] = 5000
override def sonatypeCentralReadTimeout: T[Int] = 60000
override def sonatypeCentralAwaitTimeout: T[Int] = 120 * 1000
override def sonatypeCentralShouldRelease: T[Boolean] = true
...
}
Argument Reference
publishAll
The mill.contrib.sonatypecentral.SonatypeCentralPublishModule/publishAll
method takes the following arguments:
username
: The username for calling the Sonatype Central publishing api. Defaults to the SONATYPE_USERNAME
environment variable if unset. If neither the parameter nor the environment variable are set, an error will be thrown.
password
: The password for calling the Sonatype Central publishing api. Defaults to the SONATYPE_PASSWORD
environment variable if unset. If neither the parameter nor the environment variable are set, an error will be thrown.
gpgArgs
: Arguments to pass to the gpg package for signing artifacts. Default: --batch, --yes, -a, -b
.
publishArtifacts
: The command for generating all publishable artifacts (ex. __.publishArtifacts
). Required.
readTimeout
: The timeout for receiving a response from Sonatype Central after the initial connection has occurred. Default: 60000.
awaitTimeout
: The overall timeout for all retries (including exponential backoff) of the bundle upload. Default: 120 * 1000.
connectTimeout
: The timeout for the initial connection to Sonatype Central if there is no response. Default: 5000.
shouldRelease
: Whether the bundle should be automatically released when uploaded to Sonatype Central. If false
, the bundle will still be uploaded, but users will need to manually log in to Sonatype Central and publish the bundle from the portal. Default: true
bundleName
: If set, all packages will be uploaded in a single bundle with the given name. If unset, packages will be uploaded separately. Recommended bundle name syntax: groupName-artifactId-versionNumber. As an example, if publishing the com.lihaoyi
requests
package, without the bundle name, four different bundles will be uploaded, one for each scala version supported. With a bundle name of com.lihaoyi-requests-<new_version>
, a single bundle will be uploaded that contains all packages across scala versions. It is recommended to set the bundle name, so that packages can be verified and deployed together. Default: No bundle name is set and packages will be uploaded separately