Closed ftomassetti closed 9 months ago
Some issues when checking for Maven Central requirements:
I see some MacOS stuff in there.
We know we are not building anything Mac-related as of now, what about just disabling Mac targets for now?
I see some MacOS stuff in there. We know we are not building anything Mac-related as of now, what about just disabling Mac targets for now?
Well, we cannot build Mac-related stuff on the CI, but the release will be triggered only from my machines (as I have the credentials for Sonatype), and my machines are mac, so we can publish Mac-related stuff. I think we can skip it if necessary
We are doing progress: the POM validation and the Signature validation are passing now.
We still have issues with the Javadoc validation and with the sources validation (that was ok before).
Reading the message for the Sources and the Javadoc validation the problem seems to be actually the same, and that is that the main jar is not present, which has nothing to do with sources or javadoc.
The problem seems that those publications have a klib instead of a jar, and that makes Maven Central unhappy
By disabling JS and Native, I could publish on Maven Central the JVM module. Perhaps we can start with that and add an issue to fix at least the JS publication. As a test I just publish version 0.1.0-RC1, which should propagate to Maven Central in 20-30 minutes.
hmm, it seems strange that klib wouldn't be supported, that's the standard publishing format for Kotlin Multiplatform.
okio is currently publishing klibs on maven central: https://repo1.maven.org/maven2/com/squareup/okio/okio-macosx64/3.6.0/
Mmm, yes, they do not seem to be publishing jars (besides the metadata jar). I see they are using a different plugin than maven-publish (https://github.com/vanniktech/gradle-maven-publish-plugin). Maybe it is worth taking a look at what they are doing
There is a chapter in the Multiplatform docs: https://kotlinlang.org/docs/multiplatform-publish-lib.html
One paragraph says:
Publications of a multiplatform library include an additional root publication kotlinMultiplatform that stands for the whole library and is automatically resolved to the appropriate platform-specific artifacts when added as a dependency to the common source set. Learn more about adding dependencies. This kotlinMultiplatform publication includes metadata artifacts and references the other publications as its variants.
And then:
Some repositories, such as Maven Central, require that the root module contains a JAR artifact without a classifier, for example kotlinMultiplatform-1.0.jar. The Kotlin Multiplatform plugin automatically produces the required artifact with the embedded metadata artifacts. This means you don't have to customize your build by adding an empty artifact to the root module of your library to meet the repository's requirements.
I see you also added Dokka. IMO worth doing that in another PR if it's not strictly necessary here.
I feel like configuring everything at the root should be enough, we shouldn't do anything with child modules.
I see you also added Dokka. IMO worth doing that in another PR if it's not strictly necessary here.
We need to produce a javadoc jar to publish on Maven Central, and I am not sure we can do that without using Dokka, as we do not have java code
Looks like you're right.
I've found this README for a publishing plugin aimed at being compatible with Kotlin Multiplatform, which has some explanation on publishing.
https://github.com/DanySK/publish-on-central/blob/master/README.md
That plugin does indeed wrap Dokka. Might be a good pick to investigate. Maybe tagging the author might also help if we're stuck 👀
Ok, if I understood correctly:
Now, the status is this looks good for Maven Central:
However when I publish these locally and try them into an example the target works but the runtime does not. Gradle can resolve the dependency on the runtime, however no library is loaded in IDEA:
I looked at the Jar being built for the runtime and it does not seem to contain classes:
So I am not sure what is going on
At least locally the problem seems to be solved by not publishing all the publications of the runtime but only the JVM one. I suspect otherwise a JAR from KMP replaces the "normal" JAR. By doing so I get a JAR that is ~400K instead of ~40K and I can have the example project (a JVM project and not a KMP project) works. I will verify that works only on Maven Central
Ok, that was probably due to a line where I overridden the artifact name. Removing that line I can publish to Maven local and those publications work
...and more problems:
I'd give that Publish to Central plugin a try, because it seems maintaining the publication code will be a nightmare (if it's already a nightmare coming up with a working solution).
I'd give that Publish to Central plugin a try, because it seems maintaining the publication code will be a nightmare (if it's already a nightmare coming up with a working solution).
I think that right now, we can get it working if we disable both native and JS when publishing on Maven Central. I am not even sure that JS users actually need the code on Maven Central. Maybe it is needed for KMP projects?
Regarding the Publish to Central plugin it states:
Unfortunatly, the Kotlin Multiplatform pre-initializes a sources jar, but not a javadoc jar, and Gradle does not allow to inspect the pom packaging or the artifact list without finalizing the publication (thus, preventing metadata to get generated).
Consequently, at the moment, the plugin only preconfigures the POM file and the signing.
I am not sure what that means. Maybe we then need to do something manually? If so, what?
Let's see if on the Kotlin Slack they can give advice: https://kotlinlang.slack.com/archives/C3PQML5NU/p1702028532744219
Unfortunately even JS consumers need a published package.
Regarding the plugin, I agree the explanation is a bit unclear. However there are sample projects under: https://github.com/DanySK/publish-on-central/tree/master?tab=readme-ov-file#kotlin-multiplatform-1
The template one has a seemingly straightforward configuration.
I am trying out a similar plugin (com.vanniktech.maven.publish) and it seems to work... I just tried publishing version 0.1.0-RC5 with it. We could see if that works once it propagate to Maven Central
The plugin was suggested in some discussion on the Kotlin Slack group
...and this seems to work!
I can run ./gradlew release --no-configuration-cache -Ptarget.is.native=false
and have the tag created, commits pushed, the release done on Maven central (without any manual step) and the version updated automatically.
I also tested the version I released (0.1.0-RC5) and it works in the examples project
Oh nice! I've seen that plugin seems to be quite popular.
I'll give a look at all the PR changes as soon as I'm back at home.
I think we covered all the issues raised, so I am merging this. If there is anything else pending I can still cover it in a follow up ticket
Fix #109
To do: