https://kotlinlang.org logo
#gradle
Title
# gradle
a

Arjan van Wieringen

01/20/2023, 2:42 PM
I am using a very basic
maven-publish
setup for a Kotlin Multiplatform project, but I am getting these notices in the logging when running the
publish
task:
Copy code
> Task :ui:base:publishKotlinMultiplatformPublicationToMavenRepository
Multiple publications with coordinates 'nl.avwie:ui-base:1.0.0-SNAPSHOT' are published to repository 'maven'. The publications 'js' in project ':ui:base' and 'kotlinMultiplatform' in project ':ui:base' will overwrite each other!
Multiple publications with coordinates 'nl.avwie:ui-base:1.0.0-SNAPSHOT' are published to repository 'maven'. The publications 'jvm' in project ':ui:base' and 'kotlinMultiplatform' in project ':ui:base' will overwrite each other!
How can I remove these notices? I am using:
Copy code
publishing {
    repositories {
        maven {
            url = uri("<https://maven.pkg.jetbrains.space/avwie/p/avwie/maven>")
            credentials {
                ...
            }
        }
    }

    publications.withType<MavenPublication> {
        artifactId = "ui-base"
    }
}
t

tapchicoma

01/20/2023, 2:50 PM
Most probably error comes from this:
Copy code
publications.withType<MavenPublication> {
        artifactId = "ui-base"
    }
Try to remove it and check if publication will not have errors
h

hfhbd

01/20/2023, 2:51 PM
One lazy option: Don’t use artifactId but the Gradle property
a

Arjan van Wieringen

01/20/2023, 2:53 PM
I have my modules in subdirectories, like
ui/base
and
ui/compose
, so without the artifact id the naming is just
base
and
ui
. But I see it works now. How can I make sure the names are still
ui-base-js
and not
base-js
?
h

hfhbd

01/20/2023, 2:56 PM
Gradle and the publishing plugin use by default the folder name. Either rename the folder or rename the project name in settings.gradle or create a gradle.properties file in the folder with
name=ui-base
a

Arjan van Wieringen

01/20/2023, 2:58 PM
Yeah, i tried the gradle.properties one, but that one doesn't work.
Is it because they are all subprojects?
Ah yes, it should be
Copy code
project(":foo").name = "foofoo"
in the main file.
v

Vampire

01/20/2023, 3:07 PM
Nah, better do
include("ui-foo")
and then
project("ui-foo").projectDirectory = file("ui/foo")
or similar in the settings script.
a

Arjan van Wieringen

01/20/2023, 3:08 PM
Okay, I could do that. But why is that better? I now have this in the root settings:
Copy code
val subProjects = listOf(
    ":ui:base",
    ":ui:compose"
).also(::include)

subProjects.forEach { path ->
    project(path).name = path.trim(':').replace(":", "-")
}
This doesn't work:
Copy code
include("ui-base")
project("ui-base").projectDir = file("ui/base")
This does:
Copy code
include(":ui-base")
project(":ui-base").projectDir = file("ui/base")
v

Vampire

01/20/2023, 3:13 PM
That's why I said "or similar", wrote it from the top of my head. 🙂 If it also works to set the name in the settings script it's maybe also ok. I just know it works fine with setting the
projectDir
, was not sure whether setting the name properly works as expected, especially as I understood you should set it in the build script, not the settings script and there it would most probably be problematic.
a

Arjan van Wieringen

01/20/2023, 3:14 PM
Ah clear, thanks 🙂
v

Vampire

01/20/2023, 3:14 PM
Nah, wait, now I remember why mine also is better. With
include(":ui:base")
you are creating two projects, the project
ui
and the project
base
below it.
With my version (the one fixed by you) you only create the project
ui-base
and set its project directory
a

Arjan van Wieringen

01/20/2023, 3:16 PM
For me it is not a problem that
ui
is also a project. It makes sense for me that i have
root -> ui -> base
but the artifacts should just be
ui-base
v

Vampire

01/20/2023, 3:17 PM
Well, whatever works for you 🙂
a

Arjan van Wieringen

01/20/2023, 3:17 PM
it works! Thanks
191 Views