https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
r

rebok

10/08/2023, 1:00 PM
Hi everybody, does anyone know a way to change the artifactId in the kotlinMultiplatformPublication, when using kotlin multiplatform and maven-publish gradle plugin?
m

mbonnin

10/08/2023, 1:04 PM
Copy code
publishing {
  publications {
    withType<MavenPublication> {
      artifactId = "foobar"
    }
  }  
}
Something along those lines ☝️
Thinking more about this, KMP has multiple publications so you want to change the base of the artifact id so that not to overwrite all the
-jvm
,
-macodArm64
, etc..
The easiest is probably to change the project name. IIRC, this is what's used by default
r

rebok

10/08/2023, 1:14 PM
I have multi-module project, so changing module names is really confusing.
m

mbonnin

10/08/2023, 1:16 PM
You might be able to overwrite:
Copy code
publishing {
  publications {
    withType<MavenPublication> {
      artifactId = "foobar-${artifactId.substringBefore("-")}"
    }
  }  
}
And wrap in
afterEvaluate{}
if that's not working (not pretty but 🤷 )
r

rebok

10/08/2023, 1:17 PM
I mean the snippet:
Copy code
publishing {
  publications {
    withType<MavenPublication> {
      artifactId = "foobar"
    }
  }  
}
makes it only generate only one artifact, and i also need platform specific ones. but i can just use artifactId = "foobar-${artifactId.split()[1]}"
👍 2
3 Views