How can I customize the name of the of published Pom file when publishing to Artifactory?

I am building a native project, and I have to build for multiple architectures. (Rhel 4 and Rhel 5).

My artifacts use classifiers, such that my artifact ‘fooBar’ version 3.11 would have the following artifact names:

fooBar-3.11-rhel4-x86_64.tar

fooBar-3.11-rhel5-x86_64.tar

This is nice because they sit nicely next to each other in artifactory as they are both the library. The problem is the .pom file.

Both of the above mentioned artifacts are built separately (due to the architectures they’re built for) and published separately. The problem is that the pom file gradle is publishing is called: fooBar-3.11.pom

This is a problem which ever of the artifacts is built second, replaces the existing .pom file with its own. So if Rhel 4 publishes first, then Rhel 5 publishes… the .pom file will contain only the rhel 5 dependencies for the pom.

I have checked and proved that naming the .pom files:

fooBar-3.11-rhel4-x86_64.pom

fooBar-3.11-rhel5-x86_64.pom

works perfectly as a solution. Gradle and Artifactory are smart enough to use correctly classified .pom file.

Problem: How to get gradle to publish a pom file WITH a classifier?

I’ve found lots of stuff about modifying the contents of a pom… and I found where the .pom files are placed in the build folder. But… in the build folder it is pom-default.xml, so obviously the file is renamed when it is published.

I am publishing with the jFrog gradle artifactory plugin… but I’m not sure if the issue is with that… or the maven publisher code.

My current theory is to disable the default pom publishing and generate an artifact containing just the pom I want to be published as well as my tar artifact…

Thank you.

Further research suggests that having two “main” artifacts (one for each of the two architectures) in a single maven folder is not supported. Even if you get two .pom files into the folder with their architecture-specific classifiers, gradle/maven will not read them and treat dependencies within them correctly.

If you have an artifact built for two different architectures, you need to find a different way to distinguish them, like putting them into different repositories, or publishing with different artifact names (just using classifier differences won’t work).

The issue is that the .pom for an artifact doesn’t have a classifier, and can only point at one ‘main’ artifact.