'maven-publish' and artifactId

(Tilo Dickopp) #1

What is the best way to set the artifactId / name when publishing with the ‘maven-publish’ plugin? If possible I want to avoid writing a settings files just to set the name. I’m using Gradle 1.5-rc-1


At is currently stands, the ‘maven-publish’ plugin uses the value of ‘project.name’ for artifactId, and modifying this value is the only way to customise the artifactId. There’s a detailed plan for making the publication coordinates customisable, but this has not yet been started.

You can influence the project name by changing the name of the directory that contains the project, or by specifying the project name in a ‘settings.gradle’ file.

(Tilo Dickopp) #3

Thank you for the answer!

(Benjamin Muschko) #4

@Daz: Do you know if there will be any work on this in 1.6? I didn’t see it on the release outlook.


At the moment it doesn’t look likely. Most of the focus is on getting things ready for Android to switch over to Gradle as the primary build system. That seems to have trumped other priorities…

(Benjamin Muschko) #6

Thanks for feedback.

(Mike Lueders) #7

As it turns out, this is possible in 1.6 (not sure about 1.5)…

publishing {
    publications {
        maven(MavenPublication) {
            pom.projectIdentity.artifactId = 'some-artifact-id'

This should be considered a temporary hack/workaround until the detailed plan referenced above is implemented (hopefully in 1.7).

(Luke Daley) #8

There is new stuff in 1.7 for this.


(Hans Marggraff) #9

Why does the maven-publish plugin not honour the archivesBaseName like the maven plugin does?


The reason is that ‘archivesBaseName’ does not describe the intent of publishing a module with some particular coordinates. We are trying to make the new publishing stuff less ‘magic’ and more descriptive. We also want to make it easy to publish multiple modules from a single project, and ‘archivesBaseName’ doesn’t make sense in this case.

Maven publish and archivesBaseName