I am using a very basic `maven-publish` setup for ...
# gradle
a
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
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
One lazy option: Don’t use artifactId but the Gradle property
a
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
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
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
Nah, better do
include("ui-foo")
and then
project("ui-foo").projectDirectory = file("ui/foo")
or similar in the settings script.
a
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
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
Ah clear, thanks 🙂
v
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
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
Well, whatever works for you 🙂
a
it works! Thanks
258 Views