{"id":21899009,"url":"https://github.com/johnsonlee/sonatype-publish-plugin","last_synced_at":"2025-04-15T18:51:37.391Z","repository":{"id":38387473,"uuid":"413317794","full_name":"johnsonlee/sonatype-publish-plugin","owner":"johnsonlee","description":"Gradle Plugin for publishing artifacts to Sonatype and Nexus","archived":false,"fork":false,"pushed_at":"2025-03-03T08:52:39.000Z","size":209,"stargazers_count":26,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T23:51:11.619Z","etag":null,"topics":["gradle","gradle-plugin","java","kotlin","maven","nexus","publish","publishing","sonatype"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnsonlee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-04T07:29:02.000Z","updated_at":"2025-03-05T20:52:51.000Z","dependencies_parsed_at":"2024-11-19T02:01:21.284Z","dependency_job_id":null,"html_url":"https://github.com/johnsonlee/sonatype-publish-plugin","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonlee%2Fsonatype-publish-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonlee%2Fsonatype-publish-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonlee%2Fsonatype-publish-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonlee%2Fsonatype-publish-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnsonlee","download_url":"https://codeload.github.com/johnsonlee/sonatype-publish-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249135231,"owners_count":21218357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gradle","gradle-plugin","java","kotlin","maven","nexus","publish","publishing","sonatype"],"created_at":"2024-11-28T14:36:53.263Z","updated_at":"2025-04-15T18:51:37.371Z","avatar_url":"https://github.com/johnsonlee.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Introduction\n\nDue to Sonatype's strict validation rules, the publishing requirement must be satisfied by every artifact which wants to be published to Sonatype.\n\nFor Java and Android library projects, the publishing configurations are very similar, but the configurations of creating publication are quite different, this gradle plugin is used to simplify the engineering complexity of publishing artifacts to [Sonatype](https://oss.sonatype.org/), developers don't need to write boilerplate publishing DSL for each project to satisfy Sonatype validation rules.\n\nThis plugin not only support publishing artifacts to [Sonatype](https://oss.sonatype.org/), but also support publishing artifacts to private Nexus repository.\n\n## Prerequisite\n\n* [Sonatype](https://oss.sonatype.org/) Account\n* [GPG](https://gnupg.org/) key\n\nFor more information, see [References](#references)\n\n## Getting Started\n\n```kotlin\nplugins {\n    kotlin(\"jvm\")\n    id(\"io.johnsonlee.sonatype-publish-plugin\") version \"1.6.1\"\n}\n\ngroup = \"\u003cyour-group-id\u003e\"\nversion = \"1.0.0\"\n```\n\nThen, execute publish tasks:\n\n```bash\n./gradlew publishToMavenLocal -x signMavenJavaPublication\n```\n\n## Configuring Environment Variables\n\nTo publish artifacts to remote maven repository, additional configurations are quired.\n\n### Sonatype\n\n* `OSSRH_USERNAME`\n\n    The account id of [Sonatype](https://oss.sonatype.org/), searching from project properties by default, otherwise searching from system env\n\n* `OSSRH_PASSWORD`\n\n    the account password of [Sonatype](https://oss.sonatype.org/), searching from project properties by default, otherwise searching from system env\n\n* `OSSRH_PACKAGE_GROUP`\n\n    The package group of [Sonatype](https://oss.sonatype.org/), e.g. `io.johnsonlee`, searching from project properties by default, otherwise searching from system env\n\n### Nexus\n\n* `NEXUS_URL`\n\n    The endpoint of Nexus service, e.g. http://nexus.johnsonlee.io/, searching from project properties by default, otherwise searching from system env\n\n* `NEXUS_USERNAME`\n\n    The account id of Nexus, searching from project properties by default, otherwise searching from system env\n\n* `NEXUS_PASSWORD`\n\n    The account password of Nexus, searching from project properties by default, otherwise searching from system env\n\n## Configuring Signing Properties\n\n* `signing.keyId`\n\n    The GPG key id (short format). In this example, the GPG key id is `71567BD2`\n\n    ```\n    $ gpg --list-secret-keys --keyid-format=short\n    /Users/johnsonlee/.gnupg/secring.gpg\n    ------------------------------------\n    sec   4096R/71567BD2 2021-03-10 [expires: 2031-03-10]\n    uid                  Johnson\n    ssb   4096R/4BA89E7A 2021-03-10\n    ```\n\n* `signing.password`\n\n    The password of GPG key\n\n* `signing.secretKeyRingFile`\n\n    The secret key ring file, e.g. */Users/johnsonlee/.gnupg/secring.gpg*\n\n    \u003e The best practice is putting the properties above into `~/.gradle/gradle.properties` \n    \u003e\n    \u003e ```properties\n    \u003e OSSRH_USERNAME=johnsonlee\n    \u003e OSSRH_PASSWORD=*********\n    \u003e OSSRH_PACKAGE_GROUP=io.johnsonlee\n    \u003e signing.keyId=71567BD2\n    \u003e signing.password=*********\n    \u003e signing.secretKeyRingFile=/Users/johnsonlee/.gnupg/secring.gpg\n    \u003e ```\n\n## Configuring Git Repository\n\nThe following git configurations are be used for generating maven POM file, please skip if already done.\n\n* `user.name`\n\n    ```bash\n    git config user.name \u003cusername\u003e\n    ```\n\n* `user.email`\n\n    ```bash\n    git config user.email \u003cemail-address\u003e\n    ```\n\n* `remote.origin.url` (optional)\n\n    The `remote.origin.url`  is available by default unless the git repository is created locally\n\n    ```bash\n    git remote add origin git@github.com:\u003cusername\u003e/\u003crepository\u003e\n    ```\n\n## Configuring Project Info\n\n* `project.group`\n\n    The `groupId` of the publication, only the root project need to configured, subproejcts will inherit from the root project\n\n* `project.version`\n\n    The `version` of the publication, only the root project need to configured, subproejcts will inherit from the root project\n\nThe `artifactId` of the publication is the `project.name` by default\n\n## Configuring License (optional)\n\nAdd a license file (`LICENSE`, `LICENSE.txt`, `LICENSE.md` or `LICENSE.rst`) into project, then the license type will be recognized automatically.\n\nFor more information on repository licenses, see \"[Supported Licenses](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository#searching-github-by-license-type)\"\n\n## Publishing Artifacts to Sonatype\n\n```bash\n./gradlew initializeSonatypeStagingRepository publishToSonatype\n```\n\n```bash\n./gradlew closeAndReleaseRepository\n```\n\n## Publishing Artifacts to Nexus\n\n### Java/Kotlin Project\n\n```bash\n./gradlew clean publish\n```\n\n### Android Project\n\nFor Android projects,  using `-x` to disable publication tasks for *debug* variants:\n\n```bash\n./gradlew clean publish -x publishDebugPublicationToMavenRepository\n```\n\nAfter release complete, the artifacts will be synced to [Maven Central](https://mvnrepository.com/repos/central) automatically\n\n## References\n\n- [OSSRH Requirements](https://central.sonatype.org/publish/requirements/)\n- [OSSRH Guide](https://central.sonatype.org/publish/publish-guide/)\n- [Generating A New GPG Key](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsonlee%2Fsonatype-publish-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnsonlee%2Fsonatype-publish-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsonlee%2Fsonatype-publish-plugin/lists"}