When using `maven-publish` gradle plugin with MPP ...
# multiplatform
r
When using
maven-publish
gradle plugin with MPP project I can use this code to customize generated
pom
(using a function
defaultPom()
defined in
buildSrc
). Can it be even more simplified somehow?
Copy code
publishing {
    publications.withType<MavenPublication>().apply {
        val kotlinMultiplatform by getting {
            artifactId = "artifactName"
            pom {
                defaultPom()
            }
        }
        val js by getting {
            pom {
                defaultPom()
            }
        }
        val jvm by getting {
            pom {
                defaultPom()
            }
        }
        val metadata by getting {
            pom {
                defaultPom()
            }
        }
    }
}
d
Simplified? Debatable, but it can be shortened by using a for loop.
r
thx for the idea
Copy code
publishing {
    publications.withType<MavenPublication>().apply {
        val kotlinMultiplatform by getting {
            artifactId = "artifactName"
        }
        names.forEach {
            getByName(it) {
                pom {
                    defaultPom()
                }
            }
        }
    }
}
d
You can also do. Although it only covers part of it,
Copy code
publications.withType<MavenPublication> {
    pom {
        defaultPom()
    }
}
if (name == "kotlinMultiplatform") artifactId = "artifactName"
I guess.
👍 1