3

Our organization has a convention for naming rpms. Typically, the rpm will have a shorter base name than the Maven project. There is also a convention around how releases are named. So we want a name like ${shortname}-${project.version}-${release}.noarch.rpm.

I want to build such rpms using the rpm-maven-plugin rather than older nmake technology.

And this is easily accomplished using the plugin's parameters. The rpm generated in the target directory has the desired name.

However, when mvn install installs this rpm into the maven repository, it insists on storing it the "maven way": ${project.artifactId}-${project.version}.rpm

I want the rpm stored in the standard maven repository directory using the name that is initially created on package.

How may I accomplish this?

Update: I tried using the maven-install-plugin (install-file goal) and did not get the results I was after. But this was partly because I wasn't invoking it properly. It wasn't being invoked. If you define an install-file goal, it must be explicitly tied to the install phase. Doing so, ie, adding a <phase>install</phase> to the configuration at least invoked the execution of the install that I wanted but it still did not allow me to name the rpm as desired.

Steve Cohen
  • 4,679
  • 9
  • 51
  • 89

1 Answers1

3

According to Karl Heinz Marbaise, a committer on the Apache Maven Project, what I am trying to do is impossible, and should not be attempted.

However, I need what I need, and have found a compromise that gives me most of that. The only thing I had to sacrifice was the assumption that the repository RPM must live in the same repository directory as the rest of the project. This is a very minor sacrifice. Once I make that, I can store the rpm, named as I want it to be, in a directory of the Maven repository, named with the short name.

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.5.2</version>
        <executions>
                <execution>
                        <id>install-rpm</id>
                        <goals>
                                <goal>install-file</goal>
                        </goals>
                        <phase>install</phase>
                        <configuration>
                                <file>${project.build.directory}/rpm/${rpm.name}/RPMS/noarch/${rpm.name}-${project.version}-${rpm.release}.noarch.rpm</file>
                                <groupId>${project.groupId}.rpms</groupId>
                                <artifactId>${rpm.name}</artifactId>
                                <version>${project.version}-${rpm.release}</version>
                                <classifier>noarch</classifier>
                                <packaging>rpm</packaging>
                        </configuration>
                </execution>
        </executions>
</plugin>

Using a groupId of ${project.groupId}.rpms rather than just ${project.groupId} allows all rpms built this way to live outside of the main branch of the repository, which is useful in our situation.

Using a version of ${project.version}-${rpm.release} rather than just ${project.version} allows the release to be incorporated into the name.

And the noarch classifier gets that into the name as well.

Steve Cohen
  • 4,679
  • 9
  • 51
  • 89