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.
Thank you for the answer!
@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…
Thanks for feedback.
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).
There is new stuff in 1.7 for this.
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.