Paulo Cereda
06/27/2024, 9:52 PM./gradlew publishKotlinMultiplatformPublicationToMavenLocal
we get a mere daflkt-0.2.0.jar
with mere 647 bytes (containing only META-INF/MANIFEST.MF
and META-INF/kotlin-project-structure-metadata.json
). When using publishJvmPublicationToMavenLocal
, we get an actual daflkt-0.2.0.jar
with 20kb. My (newbie) question is, since our project builds for JVM only (so far), shouldn't we get the same .jar
? And things get even more confusing when we use the actual publishKotlinMultiplatformPublicationToGitLabRepository
triggered by our CD/CI: we get two daflkt-0.2.0.jar
files in the package registry (the ones I described above: one with 647 bytes with no classes and the correct one with 20kb). When testing implementation("org.islandoftex:daflkt:0.2.0")
, the empty one is fetched. We are a bit puzzled on what to do. We are surely doing something wrong, but we cannot find what's happening. Any suggestion is welcome! (our build.gradle.kts
is available in the linked repo). Thanks in advance!Landry Norris
06/27/2024, 10:03 PMLandry Norris
06/27/2024, 10:04 PMPaulo Cereda
06/27/2024, 10:15 PMpublish
is an alias for the KotlinMultiplatformPublication
task:
➜ ./gradlew clean publish
> Task :publishKotlinMultiplatformPublicationToGitLabRepository FAILED
...
(running locally)
Also, thanks for mentioning the redirection! Unfortunately, foo-jvm
is not generated with the actual name (I understood the 20kb file should actually be daflkt-0.2.0-jvm.jar
), so we cannot fetch it from implementation("...")
. We are still a bit puzzled. 😅Oleg Smirnov
06/28/2024, 5:31 AMpublish
task (or publishToGitLabRepository
- should not matter) in your CI/CD and everything should be fine after that
> It seems publish
is an alias for KotlinMultiplatformPublication
It is not like that. publish
task is an “aggregator” for all publications you have in your project. This includes kotlinMultiplatform
and publications for all targets. And all those publications should be published together. Otherwise, the dependencies resolution in gradle won’t work when you use the library as a dependency.
Also, as I can see there is no daflkt-jvm
artifact published in the registry for version 0.2.0. Probably, this is the reason why you cannot fetch the artifact (and, most likely, it was not published because you used only a task to publish multiplatform artifact)Oleg Smirnov
06/28/2024, 5:37 AMpublishToMavenLocal
task when you checking how the publication works locally (but you probably will have to disable artifact signing). It is an equivalent for publish
task but all artifacts will be published to your local maven repoOleg Smirnov
06/28/2024, 5:45 AM>Task :publishJvmPublicationToGitLabRepository
Multiple publications with coordinates 'org.islandoftex:daflkt:0.2.0' are published to repository 'GitLab'. The publications 'jvm' in root project 'daflkt' and 'kotlinMultiplatform' in root project 'daflkt' will overwrite each other!
This is actually the reason why you don’t have jvm artifact publishedOleg Smirnov
06/28/2024, 6:02 AMit.artifactId = "daflkt"
The artifact ID will be automatically generated by kotlin plugin based on the project name and the target. So, you can simply remove this part.
Also, I would suggest moving version manipulation from publications block to the version
property.
Like this:
version = project.spotlessChangelog.versionNext.toString() +
if (project.status.toString() == "development") "-SNAPSHOT" else ""
In this case you can completely remove group, artifactId and version changes in publications block.
And you can use publications.withType<MavenPublication> {}
method to configure publications instead the one you use right nowOleg Smirnov
06/28/2024, 6:04 AMPaulo Cereda
06/28/2024, 6:24 AMbuild.gradle.kts
file! 🕵️♂️ I will proceed as you suggested. Also, sorry to @Landry Norris for misunderstanding publish
. 😅 I will check the docs too. Cheerio!Paulo Cereda
06/28/2024, 10:10 AM