https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
v

Vivek Modi

05/13/2022, 10:42 AM
Hey guys, Can somone help me on publishing library on maven repository. I am new in publish library. Actually my goal is to publish artifact in private repository. But I start from basic. I have knowledge to store
mavelLocal
. I want to learn more. Thanks
a

Anton Lakotka [JB]

05/13/2022, 11:26 AM
You can start from here https://docs.gradle.org/current/userguide/publishing_maven.html The only important aspect you need to know is that the Kotlin Gradle Multiplatform plugin is setting up a publication for you already. So you don't need to create new one like that:
Copy code
publications {
        create<MavenPublication>("maven") {
You need to define only
repositories
inside
publications
.
If you want to practice and I'd suggest, starting not with Kotlin Multiplatform, but just creating some plain and simple Gradle publications. Learn how they work, and then continue with Kotlin MPP details.
👍 1
l

Landry Norris

05/13/2022, 1:17 PM
Make sure to check all the tasks too. The first time I tried to publish a KMM library, I was calling a task that was meant for jvm, and was wondering why I couldn't import it in a KMM project.
v

Vivek Modi

05/13/2022, 1:19 PM
Sure thanks @Landry Norris I'll remember. If anything I'll ask you.
thank you @Anton Lakotka [JB] for your suggestion. I'll start with simple gradle publications
l

Landry Norris

05/13/2022, 1:43 PM
When you create your group in the SonaType Jira (if using mavenCentral), they'll need you to prove that you own the domain by adding a txt file if it's a site or creating a repo if using github. I would highly recommend doing this as soon as you create the ticket to make things faster. I did that, and they were able to create my account without having to add a comment to my ticket and wait for me to respond. Also, for github accounts, the domain is io.github.{your-account-name}, for example, io.github.landrynorris for me.
v

Vivek Modi

05/13/2022, 2:22 PM
Right now I'll learn basic and when I understand fully then I'll start looking the publish in github. Thank you so much
One question can we upload our artificat in github only? I don't have experience in SonaType or any other platforms to use. I don't want to use any other platforms rather than github because my supervisor will not allow to use any thing accept github. Thanks
l

Landry Norris

05/13/2022, 2:29 PM
GitHub added a new packages feature to host a maven repo, but you have to set that up when using the library. If you want your users to be able to use the library with mavenCentral(), that's where SonaType comes in. When you do that, GitHub is just your domain for your group if you choose to use it. Groups are how you identify whose library it is. If I want library abc, maybe there's abc for org.jetbrains, io.github.a-user, dev.gitlive, etc. The user specifies 'I want library abc from org.jetbrains' and maven finds a library with the matching name, group, and version. It takes a minute to understand, so I'd look to read a few articles and maybe spend some time looking at mavenLocal. Try to understand the ~/.m2 folder, since that's like what it will look like after publishing.
If you want to use GitHub package registry instead, you can look up how to do that, but know that users will have to add your github to their repositories block in gradle, while with SonaType, the user just needs mavenCentral.
v

Vivek Modi

05/13/2022, 2:38 PM
@Landry Norris thank you so much for explaining me in details. I'll try to read some doc and if I face any difficults then I'll ask you