Fork me on GitHub

Usage Scenarios

Listed below are the various scenarios where the RPM plugin can be used along with the proper way to configure the project(s) involved.

RPM on Demand

In this scenario, an RPM is generated from the project on demand by executing the goal "rpm:rpm" within a project. The project itself may be configured to produce any sort of packaging, since the RPM is not the primary artifact produced by the project.

If you want the project's artifacts packaged in the RPM, you must generate the RPM as a side effect of the standard lifecycle.

Things which do not work as I envision the 1.0 release working:

  • If this goal is run on a project with modules, it will run the "rpm:rpm" goal on each module, rather than packaging the modules into a single RPM.

RPM as Side Effect

In this scenario, an RPM is generated from the project whenever the project is packaged. This must be done whenever the project's primary artifact is intended to be part of the RPM package but can be done anytime. To set up this configuration, include the following lines in the plugin definition in the project's POM file (see the sample configuration for an example of this):

<executions>
  <execution>
    <id>generate-rpm</id>
    <goals>
      <goal>rpm</goal>
    </goals>
  </execution>
</executions>

RPM as Secondary Artifact

In this scenario, the rpm is not the primary artifact, but will be deployed as a secondary artifact.

<executions>
  <execution>
    <id>attach-rpm</id>
    <goals>
      <goal>attached-rpm</goal>
    </goals>
  </execution>
</executions>

RPM as Primary Artifact

In this scenario, the RPM is the primary artifact of the project and is created by executing the phase "package" within the project. If properly configured, this allows the user to execute "mvn package" on a top-level project (which has the items to build and the RPM project as modules) and have Maven package the items to build into jars, wars, ears, etc. and them assemble the RPM of those items for distribution.

The packaging value should be set to "rpm".

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
    <modelVersion>4.0.0</modelVersion>
    ...
    <packaging>rpm</packaging>
    ...
</project>

The extensions tag for this plugin should be marked true.

    <build>
      <plugins>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>rpm-maven-plugin</artifactId>
          <version>2.3.0</version>
          <extensions>true</extensions>
           ...
        </plugin>
      </plugins>
    </build>

Configure GPG passphrase under settings.xml

GPG passphrase can be configured under local settings.xml either in clear or encrypted text.

<settings>
  [...]
  <servers>
    [...]
    <server>
      <id>gpg.passphrase</id>
      <passphrase>clear or encrypted text</passphrase>
    </server>
  </servers>
</settings>