Hello folks, I'm using the `"com.vanniktech.maven....
# gradle
r
Hello folks, I'm using the
"com.vanniktech.maven.publish"
plugin in a multi-module project where each of the modules has publishing information specified in the build.gradle file. For example:
Copy code
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinMultiplatform
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.androidLibrary)
    alias(libs.plugins.kotlinSerialization)
    alias(libs.plugins.vanniktechMaven)
    alias(libs.plugins.dokka)
}

publishing {
    repositories {
        maven {
            name = "local"
            url = uri(System.getProperty("user.home") + "/.m2/repository")
        }
        maven {
            name = "githubPackages"
            url = uri("....")
            credentials(PasswordCredentials::class)
        }
    }
}

mavenPublishing {
    configure(
      .......
        )
    )
    // Define coordinates for the published artifact
    coordinates(
        groupId = "com.example.lib",
        artifactId = "example",
        version = "1.0.0"
    )

    // Configure POM metadata for the published artifact
    pom {
        name.set("....")
        description.set("....")
        inceptionYear.set("...")
        url.set("....")

        // Specify developers information
        developers {
            developer {
                id.set("....")
                name.set(".....")
            }
        }
Is there a good way to centralize all of the configuration in one place while still allowing to set the pom and coordinate values individually for each module? Edit: I explored the build-logic module option with a convention plugin but couldn't make it work for what I believe where limitations with the plugin itself, so that's probably not an option.
v
Well, a convention plugin is the way to centralize build logic. Maybe you should elaborate on "couldn't make it work". Besides that, a few points: • Your question is off-topic here as it has no specifics about Kotlin • You should optimally never change coordinates on publishing, but adjust your project group, project name, and project version so that no manipulation is necessary or there are several drawbacks in certain situations • Your
local
repo can be simplified to
mavenLocal()
• Your
local
repo can be removed, as you always have
publish...ToMavenLocal
automatically • You should avoid using Maven Local wherever possible and if you really really really need it, restrict it as far as you can with content filters or you make your builds flaky and slow
m
Make an extension that wraps
mavenPublish
and that only takes the per-module settings as input