https://kotlinlang.org logo
#amper
Title
# amper
c

christophsturm

12/01/2023, 12:51 PM
is there an example how to publish a jvm library to maven central with amper? (possible via gradle interop)
a

Anton Prokhorov

12/01/2023, 4:37 PM
As amper (at least for now) is based on kotlin/multiplatform plugin, built-in maven publication preserves multiplatform maven packaging layout, so in case if have library with only
jvm
platform built-in
publish
task will publish 2 publications: • kotlin metadata artifact with default coordinates • separate
jvm
artifact with
-jvm
suffix Until your jvm library is supposed to be consumed by gradle or amper, you are already good to go (gradle dependency resolution mechanism knows how to treat multiplatform libraries and how to use only jvm-part even in java-based projects, because kmp tooling relying on variant-aware dependency resolution mechanism) To change
artifactId
you could set up project name in
settings.gradle.kts
Copy code
// settings.gradle.kts
// rootProject.name = "new-shiny-artifactId"
project(":subproject").name = "new-shiny-artifactId"
groupId
and
version
you could set up in
build.gradle.kts
Copy code
// build.gradle.kts
group = "org.jetbrains.publication-example"
version = "1.0"
However, if you want to publish your library like a regular jvm library, you could just publish only
jvm
part, but to get rid of
-jvm
suffix in coordinates, I'd propose to just override
artifactId
field in
jvm
publication like this:
Copy code
// build.gradle.kts
publishing {
    publications {
        (findByName("kotlinMultiplatform") as MavenPublication).artifactId = "artifact-id"
    }
}
plus1 1
c

christophsturm

12/01/2023, 5:56 PM
how is the uploading to maven central handled? in gradle i currently use the gradle nexus publish plugin. https://github.com/gradle-nexus/publish-plugin
👀 1
a

Anton Prokhorov

12/01/2023, 6:00 PM
You are able to add
plugins
section in your
build.gradle.kts
and add plugin you need, I don't know how this publish plugin works, but I suspect it gets data from
PublishingExtension
anyway
c

christophsturm

12/01/2023, 6:01 PM
ok but it can handle nexus uploads without the plugin? how do I set the credentials?
a

Anton Prokhorov

12/01/2023, 6:03 PM
how do I set the credentials?
by the same way as you are used to
6 Views