Hey guys, how can I create a sample KMM project in...
# multiplatform
r
Hey guys, how can I create a sample KMM project in my library? should I create a full normal KMM project and just put it in the directory of my library?
Hey @Jan Holešovský do you might know? since i know you created a big decimal library 😄
👋 1
or a directory of multiple samples like in moko-permissions so an Android sample and KMM sample
j
I've created an example directory with full KMP standalone projects within it in my library: https://github.com/jeffdgr8/kotbase/tree/main/examples
r
cool
and is
example
a module or a normal directory ?
j
Just a normal directory.
r
alright thank you!
btw my library is just a datetime extensions library, do you think a sample is needed? and if yes, does it need a Ui? not sure what would be recommended here
j
It's up to you, what you think may be helpful. If you think a single sample would be appropriate, you could also just have a sample directory that contains that project. If UI isn't necessary to demonstrate the library's usage and capabilities, generally simpler is better.
1
j
If it is a date/time library, another possibility might be unit tests 🙂 They are always good for development and maintenance, and could show the usage too..
r
Thanks both, that sounds like a great idea @Jan Holešovský! will do that then, no need for a sample project
QQ: where do you think its best to publish the library? jetpack.io as its easier? or maven as it doesn’t require the other devs to implement another source (jetpack) ? can’t seem to find enough detailed resources on the maven one
j
Assuming you mean jitpack.io, it doesn't support Kotlin Multiplatform, yet. Maven Central is generally the best place to publish an open source library. I used this Gradle plugin, which works well for publishing KMP libraries.
1
r
ah thanks for pointing out
Hey again @Jeff Lockhart I have a couple of questions regarding publishing to maven central I’m using the plugin you shared and one of the things I can configure according to their website is the timeout period
but do you know where to put those values?
and I’m facing an issue as well with signing a KMP library, I get this error, any idea how to fix it?
Execution failed for task ‘sharedsignIosArm64Publication’.
j
I didn't set those timeout values myself, just using the defaults. My guess is they are set in gradle.properties though.
1
Did you create a GPG key pair? Are you calling
signAllPublications()
to set up automatic signing?
Be sure you follow all the instructions to set up signing and publication. This is how I set up publication in my project.
r
1. timeout, not important we can ignore for now 2. yes here is my gradle code for maven
Copy code
mavenPublishing {
    coordinates("com.raedghazal", "kotlinx_datetime_ext", "1.0.0")

    publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.S01)
    signAllPublications()
}
I didn’t specify pom, license, scm or any of this as I thought its optional, or it isn’t?
j
Maven Central has these requirements.
r
alright added
Copy code
developers
scm
let me try now
it keeps failing on the same task
:shared:signIosArm64Publication
now sure why 😕
gradle code
Copy code
mavenPublishing {
    publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.S01)
    signAllPublications()
    coordinates("com.raedghazal", "kotlinx_datetime_ext", "1.0.0")

    pom {
        name.set("Kotlinx datetime ext")
        description.set("A KMM library that provides extensions and helper functions for kotlinx-datetime ")
        inceptionYear.set("2023")
        url.set("<https://github.com/RaedGhazal/kmm-kotlinx-datetime-ext>")
        developers {
            developer {
                id.set("RaedGhazal")
                name.set("Raed Ghazal")
                url.set("<https://github.com/RaedGhazal>")
            }
        }
        scm {
            url.set("<https://github.com/RaedGhazal>")
            connection.set("scm:git:<git://github.com/RaedGhazal/kmm-kotlinx-datetime-ext.git>")
            developerConnection.set("scm:git:<ssh://git@github.com/RaedGhazal/kmm-kotlinx-datetime-ext.git>")
        }
    }
}
1: Task failed with an exception. ----------- * What went wrong: Execution failed for task ‘sharedsignIosArm64Publication’.
org.bouncycastle.openpgp.PGPException: checksum mismatch at 0 of 20
just to confirm that my properties are correct first 2 are the same username and password for sonatype right?
Copy code
mavenCentralUsername=Raed.O.Ghazal
mavenCentralPassword=
and those 3 are the last 8 digits of the key, the pass phrase I used when I generated the key, and the path to secring.gpg that I generated using a command
Copy code
signing.keyId=
signing.password=
signing.secretKeyRingFile=/Users/raedghazal/.gnupg/secring.gpg
correct?
j
This all looks correct, yes.
r
Hmm
Not sure why its failing then
j
And your credential properties are in ~/.gradle/gradle.properties?
r
Yes
And I know its reading them cuz it gave me an error on key id when i had the full 40 char put
j
Generate a new key as a last resort.
r
ok let me see
hey I noticed while writing my pass phrase in the terminal
it adds 2 characters for each character I type
is that a known thing? it can be this issue that then writing my pass phrase in the gradle.properties doesn’t match
j
That's weird. I'm not sure what would be causing that, but does seem likely it could be the problem.
You can double check your password by accessing the key in the terminal too.
r
I copied it then pasted it here and it looked like it worked
running the task now, lets see what happens
looks like its working 👀
ok great, new exception 😅 I have to specify the license
is there a way to just not add anylicense? people are free to use, modify, collaborate, download the library
j
By default, no license doesn't allow free use. You need to license under an open source license to explicitly allow that. MIT license is usually the most straightforward. https://choosealicense.com/
r
cool let me try that then
can I use this https://opensource.org/license/mit/ as a url?
not sure if the
url.set()
is checked or have specific allowed values
j
That should be fine. I don't think it checks the URL, it just needs to be present. Best to use something official that'll be active indefinitely. It's also best practice to place the license text itself in a LICENSE file at the root of your repository.
1
r
sure, thanks!
👍🏼 1
finally
🎉 1
Copy code
implementation("com.raedghazal:kotlinx_datetime_ext:1.0.0")
up and running! thanks a lot
👍 2
will still require some documentation and writing haha but its finally up, now i know why maven is the real official repo for libraries, cuz it requires real commitment and drive to put your library in there xD its real hell of a lot of steps
💯 1