Skip to content

fork of KMP Library template by JetBrains, modified for the new Nexus Publisher API

License

Notifications You must be signed in to change notification settings

snnaplab/multiplatform-library-template-nexus-publisher

 
 

Repository files navigation

Multiplatform library template, for Nexus Portal Publisher API

This is a fork of JetBrains Kotlin Multiplatform Library template, suited for the new Nexus Portal Publisher API. All new Sonatype Nexus registrants since Feb. 1st. 2024 have to use the new API instead of traditional Maven API over https://central.sonatype.com - while this JetBrains project template is still based on the traditional version.

For any newcomers to Sonatype Nexus, the JetBrains template is simply not usable.

This fork is to fix that situation, with using vanniktech/gradle-maven-publish-plugin.

Many parts of the original template is still alive. You can try publishing on GitHub Actions by manually starting the deployment workflow ("Deploy to central").

You can see what are different from the original template by diff -ur their-repo this-repo.

This modified version bumped Gradle version too though, so that the latest stable IDEA does not refuse to open because 8.1 is too old for it.


What is it?

It is the barebones library project intended to quickly bootstrap a Kotlin Multiplatform library, that is deployable to Maven Central.

It has only one function: generate the Fibonacci sequence starting from platform-provided numbers. Also, it has a test for each platform just to be sure that tests run.

Note that no other actions or tools usually required for the library development are set up, such as [tracking of backwards compatibility] (https://kotlinlang.org/docs/jvm-api-guidelines-backward-compatibility.html#tools-designed-to-enforce-backward-compatibility), explicit API mode, licensing, contribution guideline, code of conduct and others.

How do I build it?

    1. If you need the Android support update namespace there too
    2. If you don't need an Android support delete the android section

At this stage, you have everything set to work with Kotlin Multiplatform. The project should be buildable (but you might need to provide actual starting values for the platforms you need).

How do I make it build on GitHub Actions?

To make it work on GitHub actions, you need to update the matrix section in gradle.yml. If you didn't change platforms in build.gradle.kts you don't need to touch anything. But still read it to understand how it works.

Also, currently, it only runs tests, but you can change this behaviour as you wish by modifying matrix and the Gradle build command

How do I deploy it to Maven Central?

The most part of the job is already automated for you. However, deployment to Maven Central requires some manual work from your side.

    • You will have to prove that you own your desired namespace
    • Create a GPG key with gpg --gen-key, use the same email address you used to sign up to the Sonatype Jira
    • Find your key id in the output of the previous command looking like D89FAAEB4CECAFD199A2F5E612C6F735F7A9A519
    • Upload your key to a keyserver, for example
    gpg --send-keys --keyserver keyserver.ubuntu.com "<your key id>"
    • Now you should create secrets available to your GitHub Actions
    1. via gh command
    gh secret set OSSRH_GPG_SECRET_KEY -a actions --body "$(gpg --export-secret-key --armor "<your key id>")"
    gh secret set OSSRH_GPG_SECRET_KEY_ID -a actions --body "<your key id>"
    gh secret set OSSRH_GPG_SECRET_KEY_PASSWORD -a actions --body "<your key password>"
    gh secret set OSSRH_PASSWORD -a actions --body "<your access token password>"
    gh secret set OSSRH_USERNAME -a actions --body "<your access token username>"
    1. Or via the interface in SettingsSecrets and VariablesActions, same variables as in 1.
    • Call deployment manually when ready in ActionsRun Workflow
    • When you see in your account on https://oss.sonatype.org that everything is fine, you can release your staging repositories and add target releaseSonatypeStagingRepository to deploy.yml after this line. This way artifacts will be published to central automatically when tests pass.

About

fork of KMP Library template by JetBrains, modified for the new Nexus Publisher API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 100.0%