I have been attempting to publish my KFile project...
# gradle
p
I have been attempting to publish my KFile project to Maven Central using (indirectly) the SQLDelight scripts. However it occurs to me that maybe someone has another, simpler, project that is an example of publishing a Kotlin multiplatform project to Maven Central. I can attest that there is significant amount of work to accomplish such as generating an account on Sonatype, generating a PGP signing key, configuring the projects POM file (in the publications closure) and probably some steps I’m forgetting. In any case, if there is a Kotlin MPP project successfully deployed to Maven Central, boyo would I love to hear about it and study the code.
For the record, I’ve got past the signing task successfully and the publish tasks appear to work (to mavenLocal) but no uploading is taking place. Does one need both the ‘maven’ and ‘maven-publish’ tasks? btw, I am using Gradle 4.10.2 and Kotliin 1.3.10 in case it matters.
Also, in a previous life, I seem to recall publishing to maven local and using some script that came from an Apache project to successfully deploy artifacts to some central repo but the details on that are very blurry. Does this approach ring bells for anyone else?
s
Have you seen the example in #multiplatform ?
m
That example uses gradle 4.7
p
And the most recent example in #multiplatform uses jcenter (Bintray). I have had some negative experiences with jcenter() (and some positive too) but when Jake Wharton expressed concern about jcenter() too, I decided to get the Sonatype (Maven Central) publishing working buoyed by the fact that SQLDelight was apparently successful. Understanding the answer to the question of why both maven and maven-publish plugins are required is the key I do believe. And secondarily how to configure both.
An update: I learned a lot recently about publishing to Sonatype (Maven Central) that was not intuitive whatsoever. The good news is that
<http://com.pajato.io:KFile:0.0.1|com.pajato.io:KFile:0.0.1>
is now up and usable on Maven Central. The bad news is that I ill understand how I got it to happen. Fwiw, I used a manual approach once my artifacts were in the local maven repo:
~/.m2/repository/…
The successful part of the journey started here: https://blog.sonatype.com/2011/10/publishing-your-artifacts-to-the-central-repository/
The big question in my mind is if I need both Gradle tasks:
publish
and
uploadArchives
. I will have the answer to that soon.
And the answer is that once all the Sonatype boilerplate is in place, only
publish
is required. Hallelujah!
Publishing puts the MPP artifacts into a staging area on the Sonatype Nexus server. Once in place, you need to press the
release
button on that staging server to get the artifacts visible from Maven Central.
i
Hey, just wanted to give a shout out to you Paul to say thank you. I couldn't figure out how to get the maven plugin working but your project cleared it up for me. I was searching all over for a sample of someone getting the new consolidated MPP project design working with sane repos like central.
p
Thank you!
i
So based on your work I was able to also get Android working combined with Dokka and a proper sources binary (as far as I can tell) for the android module. Afaik, no one else has gotten all the pieces working together properly yet or if they have, I wish I could have found their project so I wouldn't have needed to spend all day on this. Again, can't thank you enough for giving me a good starting point. https://github.com/ToxicBakery/Arbor/blob/master/common/build.gradle snapshots: https://oss.sonatype.org/content/repositories/snapshots/com/ToxicBakery/logging/
p
There is a little more work to do in this “publishing” thread that I will get to shortly unless someone beats me to it and provides the answer here. Specifically using jcenter() and the bintray gradle plugin to publish a multiplatform library or app. Publishing to jcenter() has the benefit of automagically having the artifacts appear on Maven Central. Sonatype has too many moving parts for my liking.
The thing I do not know yet is whether or not Bintray also has additional manual steps after the gradle plugin has been applied. I’m guessing that it does.
i
Understandable. It won't be me beating you to it on that front as I only use central directly.