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.
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.
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?
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 { asNode().appendNode('classifier',"${buildNumber}") } } } }
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/MyProject-1.5.24-b36.zip
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
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 http://maven.apache.org/xsd/maven-4.0.0.xsd, 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.
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.
com/mycompany/MyProject/1.5.24-b36/MyProject-1.5.24-b36.zip
com/mycompany/MyProject/1.5.24-b37/MyProject-1.5.24-b37.zip
com/mycompany/MyProject/1.5.24-b38/MyProject-1.5.24-b38.zip
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 …
repo/com/mycompany/MyProject/1.5.24/
MyProject-1.5.24-b36.zip
MyProject-1.5.24-b37.zip
MyProject-1.5.24-b38.zip
repo/com/mycompany/MyProject/1.5.25/
MyProject-1.5.25-b36.zip
MyProject-1.5.25-b37.zip
MyProject-1.5.25-b38.zip
Does anyone have experience customizing/configuring the generatePomFile plugin to rename pom? Or any other ideas on this …