mavenPublish_ method setArtifacts not working as expected


(Carlo Luib-Finetti) #1

Some weeks ago I tried to get help for a problem (How to publish different build artifacts from the same subproject?). Sadly, I got no answer. :frowning:

After retrying to solve my problem, I come to the opinion that there is a bug in the Maven publishing implementation.
The docs say “Clears any previously added artifacts from MavenPublication.getArtifacts() and creates artifacts from the specified sources”.
In my subproject I’m overwriting publishing with this

publishing.publications {
mavenJava(MavenPublication) {
artifacts = [ serverJarWithoutAnnoProfile ]
}
}

Which means, for my understanding: publishing should just take the artifact from the task ‘serverJarWithoutAnnoProfile’. The expected jar from this task is built by the task, but not this jar is uploaded; instead publishing uploads the regular jar for this subproject which is not what I expect it to do.