How to control the name of an archive deployed into Maven repo


(Steve Cohen) #1

I am using the os-nebula plugin as a basis on which to build other plugins that build rpms. I have these working the way I want them to.

However, now I wish to add the capability to publish the outputs of these plugins back into a maven repository.
I have set my plugin to apply the maven-publish plugin and it works almost as I’d like it to. But not quite. I have this code:

        project.publishing {
            publications {
                maven(MavenPublication) {
                    groupId 'my.group.id'
                    artifactId rpmTask.rpmName
                    version rpmTask.version
                    artifact rpmTask
                }
            }
        }

However, my rpm’s have a release identifier in the name. That is how I want them to go into the repository as well. In other words if the release name is rms, the artifactId is mylib, and the version is 12.0.0, the rpm plugin will generate mylib-12.0.0-rms.rpm, but when it’s placed in the repo, it comes out as just mylib-12.0.0.rpm. It’s easy enough to see why, I haven’t specified the release in the publication spec. But how do I specify it? release is not a property of the publication and neither is classifier which I might ordinarily expect. Is there some way to force the name to be what I want?

Or am I barking up the wrong tree? Is there another kind of publication that would be easier to customize to my needs? I chose maven publishing only because I’m familiar with it, and because in an earlier iteration of this effort that used Maven I got it to work.


(Steve Cohen) #2

Figured it out.

        project.publishing {
            publications {
                maven(MavenPublication) {
                    def release = rpmTask.release
                    groupId 'my.group.id'
                    artifactId rpmTask.rpmName
                    version rpmTask.version
                    artifact(rpmTask) { 
                        classifier release
                    }
                }
            }
        }

classifier is a property of the archive, not of the publication. I don’t quite understand how this all works, but it gets me what I need.


(Stefan Oehme) #3

A publication can contain several archives (jars, poms, documentation etc.), each with their own classifier.