How do I include the artifact classifier in the generated pom file name?

(Bradley) #1

How do I get the generated pom to include the classifier?

I’m using a custom layout in artifactory repo’s and MavenPublishing in gradle. generatePomFileForMyProjectPublication seems to ignore the classifier in generating the pom.

(Chris Doré) #2

Classifiers are not part of Maven module identifiers (group, name, version). Classifiers differentiate module artifacts from the default artifact (no classifier) and any other artifacts with classifiers.

Are you trying to have the classifier included as part of the published modules name?
If so, you are actually creating a publication with a different name, in which case you don’t want to use classifiers at all.
If not, where are you trying to use the classifier that is being ignored?

(Bradley) #3

I do have the classifier included in the published modules name.

My publish task in gradle looks like this

publishing {
	publications {
		projectZipPub(MavenPublication) {
			groupId "${project_groupid}"
			version "${projVersion}"
			artifactId "${projArtifactName}"
			artifact projectZip {
			                classifier "${buildNumber}"
			pom.withXml {
artifactoryPublish {
    publications ('projectZipPub')

Based on my layout this causes a deploy that looks like so

Deploying artifact: https://artifactoryurl/artifactory/repo/com/mycompany/MyProject/1.5.24/
Deploying artifact: https://artifactoryurl/artifactory/repo/com/mycompany/MyProject/1.5.24/MyProject-1.5.24.pom

Where version is 1.5.24, and build is b36.

The filename of the pom ignores the classifier I added for the artifact. This results in subsequent builds overriding the pom in artifactory. I’d like to instead create a pom for each build so I can capture any changes.

Deploying artifact: https://artifactoryurl/artifactory/repo/com/mycompany/MyProject/1.5.24/MyProject-1.5.24-b36.pom

(Chris Doré) #4

I’m not sure that what you want to do will result in a valid maven repository (but I’ll admit that I’ve only ever dealt with standard maven repo layouts and I haven’t worked with custom layouts). In my experience it has always been expected that the pom file is named “artifactid-version.pom”.

Also, I’m not sure that your pom.withXml is actually a valid use of classifier (I’ve only ever seen it used when declaring dependencies, not when defining a module/project). Looking at, I don’t see classifier being part of the project element, so I doubt any tools will recognize or use it for anything.

Can you make the build number part of the version? That’s how I handle my builds since I consider a new build to be a new version of the module.

(Bradley) #5

I’m actually attempting to redo this from a structure where the build number is part of the revision.

That method had unwieldly repo structure where each leaf had one build in it and thousands of leafs.


This structure also affected me being able to retain the last n artifacts for a version using artifactory retention policy

One of my goals is to have a more human friendly custom structure where each version had all its builds under 1 parent and where I can n of the latest based on version. So it would look like this …


Does anyone have experience customizing/configuring the generatePomFile plugin to rename pom? Or any other ideas on this …