# Publishing your Kotlin Multiplatform library to Maven Central

DevFeed: [Publishing your Kotlin Multiplatform library to Maven Central](<https://devfeed.tech/articles/publishing-your-kotlin-multiplatform-library-to-maven-central-22983.md>)

Original publisher: [Read original article](<https://dev.to/kotlin/how-to-build-and-publish-a-kotlin-multiplatform-library-going-public-4a8k>)

Author: Ekaterina Petrova

Published: 2021-03-25T12:40:40Z

Content type: tutorial

Language: en

Sources: [Kotlin](<https://devfeed.tech/sources/kotlin-2.md>)

Topics: [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [Maven Central](<https://devfeed.tech/topics/maven-central.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [Library](<https://devfeed.tech/topics/library.md>), [Publishing](<https://devfeed.tech/topics/publishing.md>)

Tags: [coding](<https://devfeed.tech/tags/coding.md>), [community](<https://devfeed.tech/tags/community.md>), [development](<https://devfeed.tech/tags/development.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [inclusive](<https://devfeed.tech/tags/inclusive.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [library](<https://devfeed.tech/tags/library.md>), [maven-central](<https://devfeed.tech/tags/maven-central.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [software](<https://devfeed.tech/tags/software.md>)

## AI overview

A tutorial on publishing a Kotlin Multiplatform library to Maven Central. It covers Sonatype account registration, group ID ownership verification, GPG key setup, Gradle publication configuration, metadata and Javadocs, and signing artifacts.

## Source excerpt

Now when we've built our first Kotlin Multiplatform library and learned about multiplatform library publishing format nothing can stop us from going public and releasing our library to MavenCentral! Registering a Sonatype account If this is your first library, or you've only ever used Bintray to do this before, you will need to first register a Sonatype account. There are many articles describing the registration process on the internet. The one from GetStream is exhaustive and up to date. You can start by following the first four steps, including "Generating a GPG key pair": Register a Jira account with Sonatype (you can use my issue as an example). ✅ Verify your ownership of the group ID you want to use to publish your artifact by creating a GitHub repo. ✅ Generate a GPG key pair for signing your artifacts. ✅ Publish your public key. ✅ Export your private key. ✅ When the Maven repository and signing keys for your library are prepared, we are ready to move forward and set up our build to upload the library artifacts to a staging repository and then release them! Setting up publication Now we need to tell Gradle how to publish our libraries. Most of the work is already done by maven-publish and Kotlin Gradle Plugins - all the required publications are created automatically. We've already seen the result when we published our library to the local Maven repository. But for publishing it to Maven Central we need to take some additional steps: Configure public Maven repository URL and credentials. Provide a description and javadocs for all library components. Sign publications. Let's handle all of these tasks by writing some Gradle scripts! I suggest extracting all the publication-related logic from our library module build.script, so you can easily reuse it for other modules in the future. The most idiomatic and flexible way to do that is to use Gradle's precompiled script plugins. Our build logic will be provided as a precompiled script plugin and could be applied by