Publish Kotlin SDKs manually
This guide covers publishing Kotlin SDKs manually. For information on automating Kotlin SDK publishing, see Publish Kotlin SDKs automatically.
To share your generated Kotlin SDK with the community, you can publish it to Maven Central. This enables other developers to easily add it as a dependency in their Maven or Gradle projects. Follow the steps below to publish your SDK to Maven Central.
Prerequisites
To publish your SDK to Maven Central, you need the following:
- Sonatype Central Portal account (central.sonatype.com).
- GPG key for signing artifacts.
- Namespace (group ID) verified on the Central Portal.
Initial setup
To set up your environment for publishing to Maven Central, do the following:
-
Create account and verify your namespace:
- Register at central.sonatype.com.
- Verify your namespace (group ID, for example,
com.example) through DNS or GitHub verification. - Verification is typically automated and completes within minutes.
-
Generate a GPG key.
-
Configure Maven
settings.xml. Add the following to~/.m2/settings.xml:
Configure pom.xml
Add the following to your SDK’s pom.xml:
Publish your Kotlin SDK to Maven Central
-
Deploy to Maven Central.
With
autoPublishset totrue, artifacts are automatically published after validation. If set tofalse, you can manually publish from the Central Portal UI at central.sonatype.com. -
Verify the publication. After deployment, verify that your artifacts are available in the staging repository on the Central Portal, for example,
https://repo1.maven.org/maven2/com/example/your-sdk/. Once verified, they’re released to Maven Central.
Publish updates
To publish updates to your SDK, do the following:
Best practices for publishing Kotlin SDKs
Use the following best practices when publishing your Kotlin SDK to Maven Central:
- Use semantic versioning.
- Sign all artifacts with GPG.
- Include source and Javadoc JARs.
- Provide comprehensive documentation.
- Tag releases in Git.
- Consider using the Maven Release Plugin for automated releases.