Closed ntoskrnl closed 3 years ago
I found a solution. For android publications the plugin's configure()
method creates a publication named "maven". We can find it by name and change artifactId
. But I just applied name to all publications (there will only be one per Gradle module anyway).
I added this to the module:
publishing {
publications.all { p ->
p.artifactId = "newname"
}
}
Thank you, @ntoskrnl, for posting your solution! This needs to be translated a little bit in order to work for the Kotlin DSL.
In Kotlin, publications
gives us a collection of Publication
, which doesn't have the artifactId
property. We need to cast that p: Publication
to a MavenPublication
.
publishing {
publications
.filterIsInstance<MavenPublication>()
.forEach { p ->
p.artifactId = "my-artifact-id"
}
}
We set up a base-plugin in our project, and the library has several modules. Pom config is set up via gradle DSL (i.e. using
pom { }
) as described in README.When I publish, the plugin uses gradle module name as
artifactId
and I would like to change it. How do I set upartifactId
for each module individually?I tried adding
POM_ARTIFACT_ID = ...
orpom.artificatId = ...
insidemavenPublishing { }
block of the module, but it didn't work.