{"id":16855127,"url":"https://github.com/him188/maven-central-publish","last_synced_at":"2025-07-31T06:33:30.793Z","repository":{"id":45819337,"uuid":"345882271","full_name":"Him188/maven-central-publish","owner":"Him188","description":"Configure publication to Maven Central for Gradle projects with minimal effort.","archived":false,"fork":false,"pushed_at":"2023-09-04T17:49:12.000Z","size":309,"stargazers_count":24,"open_issues_count":7,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-20T08:47:42.923Z","etag":null,"topics":["gradle","maven","publishing"],"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/Him188.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-03-09T04:27:26.000Z","updated_at":"2024-07-18T09:16:12.000Z","dependencies_parsed_at":"2024-10-28T17:46:05.538Z","dependency_job_id":null,"html_url":"https://github.com/Him188/maven-central-publish","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/Him188/maven-central-publish","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Him188%2Fmaven-central-publish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Him188%2Fmaven-central-publish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Him188%2Fmaven-central-publish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Him188%2Fmaven-central-publish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Him188","download_url":"https://codeload.github.com/Him188/maven-central-publish/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Him188%2Fmaven-central-publish/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267998080,"owners_count":24178451,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","maven","publishing"],"created_at":"2024-10-13T13:58:33.601Z","updated_at":"2025-07-31T06:33:30.768Z","avatar_url":"https://github.com/Him188.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# maven-central-publish\n\nConfigure publication to Maven Central repository for Gradle projects with minimal effort.\n\n## Why this plugin?\n\n### Pack credentials once, use anywhere\n\nYou can pack your Sonatype and GPG keys once, then use it around any projects directly. You can add it into your global\ngradle.properties or store in GitHub secretes for Actions.\n\n### Automatic signing\n\nThe plugin automatically signs all the artifacts using your GPG keys from the pre-set credentials. So you don't need any\nother steps for it. Also, no concerns on the singing and publishing integration!\n\n### Automatic configuration for usual Java and Kotlin projects\n\nThis simplest configuration applies to most projects:\n\n```kotlin\nmavenCentralPublish {\n    singleDevGithubProject(\"Him188\", \"maven-central-publish\")\n    licenseApacheV2()\n}\n```\n\nBy running 'publish', everything will be done by the plugin.\n\n### Predictable artifacts configuration\n\nThe plugin provides a task `previewPublication` allowing you to know everything about the project being published. An\nexample\n\n### Full support for Kotlin Multiplatform (KMM)\n\nThe plugin supports not only KMM with Native targets, but hierarchical multiplatform projects.\n\nFor example a nativeBaseMain with androidArm64Main and iosArm64Main depending on it.\n\nHierarchical JVM projects are also supported: a shared jvmBaseMain with jvmDesktopMain and androidMain.\n\n### Platform artifacts in KMM root module\n\nWhen your multiplatform project targets JVM, you can set `publishPlatformArtifactsInRootModule=\"jvm\"` to allow the\nplugin to add a dependency to the jvm module on the root module.\n\nThis enables users who can not access Gradle Metadata to add dependency using the root module without '-jvm' suffix.\n\n## Using the plugin\n\n```kotlin\nplugins {\n    id(\"me.him188.maven-central-publish\") version \"1.0.0-dev-1\"\n}\n```\n\n## Step-by-step tutorials\n\nYou can read these tutorials if you are new to publishing. Also, you can continue reading this article for quick\nreference.\n\n- [How to use this plugin in a local project](UseInLocalProject.md)\n- [How to use this plugin in CI environment](UseInCI.md)\n\n## Configuring the plugin\n\nThe plugin adds a `mavenCentralPublish` configuration. This chapter shows some handy examples.\n\nSee [MavenCentralPublishExtension](plugin/src/main/kotlin/me/him188/maven/central/publish/gradle/MavenCentralPublishExtension.kt)\nfor full details for each property.\n\n### Basic configuration\n\nAs required by Maven Central, you would need\n\n- project id and group ---- `[Project.getName]` and `[Project.getGroup]`\n- project name ---- `[Project.getName]`\n- project description ---- `[Project.getDescription]`\n- project url ---- `[projectUrl]`\n- project SCM ---- `[connection]`\n- project licenses ---- `[license]`\n- project developers ---- `[developer]`\n\nIt would be easier to keep your `project.name`, `project.group`, `project.version` same as which you want to use for\nyour published artifacts.\n\nA recommended, minimal, manual configuration is:\n\n```kotlin\nmavenCentralPublish {\n    // If different from that from project, specify manually:\n    artifactId = \"kotlin-jvm-blocking-bridge-runtime\"\n    groupId = \"me.him188\"\n    projectName = \"Kotlin JVM Blocking Bridge Runtime\"\n    // description from project.description by default\n\n    url = \"https://github.com/him188/kotlin-jvm-blocking-bridge\"\n    connection = \"scm:git:git://github.com/him188/kotlin-jvm-blocking-bridge.git\"\n    license(\"Apache-2.0\", \"https://www.apache.org/licenses/LICENSE-2.0\")\n\n    developer(\"Him188\")\n}\n```\n\nHowever, configuration for GitHub projects can be simplified:\n\n```kotlin\nmavenCentralPublish {\n    // If different from that from project, specify manually:\n    artifactId = \"kotlin-jvm-blocking-bridge-runtime\"\n    groupId = \"me.him188\"\n    projectName = \"Kotlin JVM Blocking Bridge Runtime\"\n\n    githubProject(\"him188\", \"kotlin-jvm-blocking-bridge\")\n    developer(\"him188\")\n    licenseApacheV2()\n\n    // and can be more simplified as \n    singleDevGithubProject(\"him188\", \"kotlin-jvm-blocking-bridge\")\n    licenseApacheV2()\n}\n```\n\n### Configuring other details\n\nThe `mavenCentralPublish { }` contain only the required information. You can add further configurators as follows. Note\nthat all these configurators override the properties in `mavenCentralPublish { }`.\n\n```kotlin\nmavenCentralPublish {\n    pom { // this: MavenPom\n        // Configures the pom. Example:\n        name.set(\"Project Name Here\") // This 'overrides' mavenCentralPublish.projectName\n        inceptionYear.set(\"2021\") // Set more optional details\n    }\n    publication { // this: MavenPublication\n        // Configures the publication.\n        groupId = \"me.him188\" // This 'overrides' mavenCentralPublish.groupId\n        from(components.getByName(\"java\")) // Add custom component if needed. You may also set `mavenCentralPublish.addProjectComponents` to `false` to disable default components.\n        artifact(tasks.get(\"myCustomJarTask\")) // You can a custom artifact\n    }\n}\n```\n\n### Supporting consumers who cannot access Gradle Metadata\n\nThis is only for Kotlin MPP with JVM targets. This enables Maven to access your project without the '-jvm' suffix.\n\n```kotlin\nmavenCentralPublish {\n    publishPlatformArtifactsInRootModule = \"jvm\" // name of your JVM target ---- it is \"jvm\" by default.\n}\n```\n\n### Integration with shadow plugin\n\nAs [described](https://imperceptiblethoughts.com/shadow/publishing/#publishing-shadow-jars), Shadow plugin automatically\nadds an artifact \"$name-$version-all.jar\" to all `MavenPublication`s. This file will be included in the publication.\n\nThis would work normally if both `mavenCentralPublish.artifactId == project.name`\nand `mavenCentralPublish.version == project.version`. However, if not, you should rename the '-all' artifact as follows:\n\n```kotlin\ntasks.withType(com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class) {\n    archiveFileName.set(\"${mavenCentralPublish.artifactId}-${mavenCentralPublish.version}-all.jar\")\n}\n```\n\n### Adding custom artifacts\n\n```kotlin\nmavenCentralPublish {\n    publication {\n        artifacts.artifact(tasks.getByName(\"myCustomJarTask\"))\n    }\n}\n```\n\n## Checking your configuration\n\nAll tasks are in the group 'publishing' like the task 'publish'.\n\n### Task `checkPublicationCredentials`\n\nEnsures publication credentials is set.\n\n### Task `checkMavenCentralPublication`\n\nEnsures project is ready to publish with all required information configured.\n\n### Task `previewPublication`\n\nHave a preview at the project structure to be published to eliminate your concerns and saves time. Example:\n\n```text\nPublication Preview\n\nRoot module:\n  GroupId: group-id\n  ArtifactId: project-name\n  Version: 1.0.0\n\nYour project targets multi platforms.\nTarget platforms include: js, jvm, common, linuxX64, macosX64\nArtifact ids are: \nproject-name-js\nproject-name-jvm\nproject-name-common\nproject-name-linuxX64\nproject-name-macosX64\n\nGradle users can add multiplatform dependency in commonMain by `implementation(\"group-id:project-name:1.0.0\")`.\nGradle users can also add jvm dependency by `implementation(\"group-id:project-name:1.0.0\")`.\n\nMaven users can only add JVM dependencies, including: jvm\n\nMaven users can add jvm dependency as follows:\n\u003cdependency\u003e\n    \u003cgroupId\u003egroup-id\u003c/groupId\u003e\n    \u003cartifactId\u003eproject-name-jvm\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n\nYou have configured to publish jvm into root module.\nSo, Maven users can also add jvm dependency as follows:\n\u003cdependency\u003e\n    \u003cgroupId\u003egroup-id\u003c/groupId\u003e\n    \u003cartifactId\u003eproject-name\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n\nPublication Preview End\n```\n\n## Troubleshooting\n\nSee [Troubleshooting.md](Troubleshooting.md).\n\n## Supporting this plugin\n\nI personally develop various libraries and publish them to Maven Central. So even without anyone's help, I will continue\nto maintain this plugin. However, it would be really lovely if you could give me a star!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhim188%2Fmaven-central-publish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhim188%2Fmaven-central-publish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhim188%2Fmaven-central-publish/lists"}