Question, is there a way to change the publication...
# multiplatform
l
Question, is there a way to change the publication names Kotlin/Multiplatform creates? It currently creates
quest.laxla.gimli:client
for the
:api:client
module, and I would like to create
quest.laxla.gimli:api.client
instead.
a
You can customize the artifact ID,
Copy code
publishing {
  publications.withType<MavenPublication>().configureEach {
    // customise artifact ID, but this is probably buggy!
    artifactId = "..."
  }
}
but it'll be tricky because there are multiple publications for KMP. The most robust way is to rename the subproject to
api.client
.
l
@Adam S the artifact ID also contains the
-jvm
part, right? So I could just do,
artifactId = "api-client" + artifactId.removePrefix(project.name)
I'll have to move the
:api:common
module to
:api
tho, so that I won't have
api-common-common
. Or wait, does the common publication even have a suffix?
a
So I could just do,
artifactId = "api-client" + artifactId.removePrefix(project.name)
possibly.... but it depends in what order that modification gets applied. It can get really tricky trying to modify the artifact ID
Or wait, does the common publication even have a suffix?
No, it shouldn't do (e.g kotest-common)
it's usually best to have distinct subproject names, because otherwise Gradle gets confused https://github.com/gradle/gradle/issues/847
l
I see, I'll rename them in settings.gradle.kts.
👍 1
I automated it, and used the opportunity to make the includes look better too.
Copy code
"util"()
"api" {
    "client"()
    "common"()
    "server"()
}