This message was deleted.
# community-support
s
This message was deleted.
a
in the
std-publishing.gradle.kts
I presume you have something like this?
Copy code
plugins {
  `maven-publish`
}

publishing {
  publications.withType<MavenPublication>().configureEach {
    pom {
      name.convention("my cool library")
      description.convention("some description")
      // ...
My second question is: where do you define a publication? Which will look something like this:
Copy code
publishing {
    publications {
        create<MavenPublication>("maven") {
            groupId = "org.gradle.sample"
            artifactId = "library"
            version = "1.1"

            from(components["java"])
        }
    }
}
m
This is the actual plugin. It is used by a KMP library (where the KMP plugin defines publication) and a JVM-only library (where build.gradle.kts defines the publication). I hope this makes sense.
a
makes perfect sense 👍
Okay cool, so your
klogging-publishing.gradle.kts
convention already sets the defaults. The simplest way to update the description is to do it in the actual
build.gradle.kts
of each project.
Copy code
// library-1/build.gradle.kts

plugins {
  kotlin("multiplatform")
  id("std-publishing")
}

publishing {
  // use configureEach {} because Kotlin automatically registers publications
  publications.withType<MavenPublication>().configureEach {
    pom {
      description.set("lib1 desc...") // override the convention plugin default by using `set()`
    }
  }
}
Copy code
// library-2/build.gradle.kts

plugins {
  `java-library`
  id("std-publishing")
}

publishing {
  publications {
    create<MavenPublication>("maven") {
        groupId = "org.gradle.sample"
        artifactId = "library"
        version = "1.1"
        from(components["java"])
        
        pom {
          description.set("lib2 desc...") // override the convention plugin default by using `set()`
        }
    }
}
My guess is that you’ve already tried to override the convention plugin values in the actual build scripts? But probably these values are being overridden by the convention plugin, which is the opposite of what a convention plugin should do! So I’d try to fix it by updating this line to use lazy evaluation
Copy code
publications.withType<MavenPublication>().configureEach {
and use
convention()
instead of
set()
, so that even if the convention plugin applies defaults to library-1 and library-2, it won’t override anything that the libraries manually set
Copy code
description.convention("Kotlin logging library with structured logging and coroutines support")
m
@Adam thanks for your really helpful reply! I found the smallest change that achieves what I want, for now. I simply added POM specification to the Maven Publication declaration:
Copy code
publishing {
    publications {
        create<MavenPublication>("jvm") {
            from(components["kotlin"])
            pom {
                name.set("slf4j-klogging")
                description.set("SLF4J provider implemented with Klogging logging library")
            }
        }
    }
}
You can see from this commit: • There is no change to the convention plugin. The POM specifies values for the Klogging library (KMP plugin), using
set()
. • The build script for the SLF4J provider library (Kotlin JVM plugin) specifies different values, also using
set()
. The generated POM contains the desired values.
set()
vs
convention()
? It is all part of the great mystery of Gradle to me!
a
ah, good that it works!
I simply added POM specification to the Maven Publication declaration:
you made that change in the specific
build.gradle.kts
for the JVM only library?
v
set()
vs
convention()
? It is all part of the great mystery of Gradle to me!
Let me demystify it for you. "convention" means it is the conventional default. So if none sets a value explicitly, that value is used and if someone sets
null
as value, also that default value is used. If you use
set
, you set the actual value and if you set to
null
, it is just that.
m
@Adam Yes, I only changed
build.gradle.kts
in the JVM-only library to override the default values, which are for the main library. If I publish another Kotlin Multiplatform library from this repository I might need to do something different.
👍 1