@@ -4,33 +4,24 @@ title: Sonatype & Maven Central
44
55# Sonatype & Maven Central
66
7- Add a new spec with ` sonatypeSpec {} ` . It adds a mandatory property called ` repositoryUrl ` , which is the remote URL
8- of the sonatype repo. This defaults to ` https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ ` -
9- the Sonatype OSSRH which can be synced to Maven Central.
10-
11- Sonatype repositories make many fields mandatory:
12- - authentication: use the ` auth ` block as shown below
13- - signing
14- - valid project url and scm
15- - at least one developer and a license
16- - possibly more
17-
18- Deployment will fail with clear errors notifying you about what's missing.
7+ Add a new spec with ` sonatypeSpec {} ` or ` nexusSpec {} ` . It adds a mandatory property called ` repositoryUrl ` , which is the remote URL
8+ of the sonatype repo. This defaults to ` https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ ` , one of the
9+ OSSRH urls that can be synced to Maven Central.
1910
2011``` kotlin
2112deployer {
2213 // Common configuration...
2314 project.description.set(" Handy tool to publish maven packages in different repositories." )
2415
2516 sonatypeSpec {
26- // Sonatype configuration...
17+ // Target URL. You can use `ossrh`, `ossrh1`, `ossrhSnapshots`, `ossrhSnapshots1` or your own URL
2718 repositoryUrl.set(ossrh1)
2819
29- // Credentials used to register the package group into the OSSRH repository...
20+ // For OSSRH projects, these are the credentials that were used to register the package group into OSSRH
3021 auth.user.set(secret(" SONATYPE_USER" ))
3122 auth.password.set(secret(" SONATYPE_PASSWORD" ))
3223
33- // Signing is required
24+ // Note: signing is required for Maven Central sync
3425 signing.key.set(secret(" SIGNING_KEY" ))
3526 signing.password.set(secret(" SIGNING_PASSWORD" ))
3627 }
@@ -43,3 +34,36 @@ deployer {
4334 }
4435}
4536```
37+
38+ ## Maven Central sync
39+
40+ Sonatype's OSSRH projects are allowed to sync artifacts with the [ Maven Central] ( https://central.sonatype.org/ ) repository.
41+ The process is generally tricky, because you have to:
42+
43+ - Build maven packages with a very strict set of rules (for example, signing is mandatory)
44+ - Deploy them to ` oss.sonatype.org/service/local/staging/deploy/maven2 ` or ` s01.oss.sonatype.org/service/local/staging/deploy/maven2 `
45+ - Access the web interface at ` oss.sonatype.org ` or ` s01.oss.sonatype.org `
46+ - Login with your credentials
47+ - Find the staging repository corresponding to the upload, ` Close ` it and then ` Release ` it
48+
49+ Deployer streamlines the process so that only the first step is really your responsibility.
50+ First, enable maven central sync using ` syncToMavenCentral ` :
51+
52+ ``` kotlin
53+ sonatypeSpec {
54+ syncToMavenCentral = true
55+
56+ auth.user = secret(" SONATYPE_USER" )
57+ auth.password = secret(" SONATYPE_PASSWORD" )
58+ }
59+ ```
60+
61+ Then simply run the deploy task. Deployer will:
62+
63+ - Validate your artifacts and POM file, to ensure they won't be rejected by the backend
64+ - Fail with clear errors if any issue is found
65+ - Use Sonatype's REST APIs to create a staging repository in your Sonatype account
66+ - Upload the artifacts
67+ - Use Sonatype's REST APIs to close and release the staging repository
68+
69+
0 commit comments