Sun. Apr 2nd, 2023

Creating RPM as a package for your software? Use Maven to generate the RPM using the details shared in this post. Let’s look into the steps and guidelines to create RPM via Maven

Maven POM Changes





Specifies the parent location of RPM installation
Example: /usr/local/my-app


Problem: relative path attribute was not working

Solution: full directory path in the mapping like shown below


Change Log File

Change log maintains a record of changes being made to the package



You can go through link to understand more about the mapping attributes.
Attributes username and groupname were retained to match the production value.
If QA has a different values for username and groupname, it was modified in post installation scripts


Local testing using maven

mvn clean package
Every time run with clean option, we have noticed at times that only package results in stale files.

Check spec file of your project.
We checked /target/rpm/project/SPECS/PROJECT.spec file
Check if permissions to users and groups are reflecting correctly and in sync with mappings of pom.xml.

List all the files present inside rpm.
rpm –qlp

Migrating from .tar to RPM

Follow these steps to change your packaging from tar to RPM

  1. Compare the lib folder in RPM with the tar (current package) lib contents.
  2. Check dependency sets in package.xml and based on the differences in previous step, include the same rules as applicable into mappings section in pom.xml.
  3. Compare the lib folder in RPM with the current production lib contents

To create the lib files
tar xf PROJECT.tar
ls -1 PROJECT/lib/ | sort > PROD
rpm -qlp | grep lib | cut -d / -f6 | sort > BUILD
diff -u BUILD PROD

Sample diff
NOTE: + file in Production, – file in current branch

Open eclipse and follow below steps.

  1. Open pom.xml
  2. Navigate to dependency hierarchy and search for -plexis-utils. Here you need to find which plugin has compiled plexis-utils-3.0.8.jar. For us, it was maven-surefire-report-plugin.
  3. In the search tab, type your jar name ex:plexis-utils, this will display all the jars starting with plexis-utils.
  4. Check which dependency has compiled this plexis-utils-3.0.8.jar.
  5. After you find the dependency, go to pom.xml and add plexis-utils in the excluded section as shown below:

Installation of RPM

  1. Command to check if RPM is installed
    yum list or
    rpm -qa

The above commands lists the installed packages for the particular project.

  1. check the target folder if all files are present and check permissions, owner, group for the same.
    ls -lR
    This command will list all the subdirectories inside the project deployment folder with all the files describing timestamp, permissions, owner, and group.
  2. Ensure latest configuration changes are reflected
  3. You can add some test statements in your files, rebuild the package and check using step 3 command if latest changes are getting reflected.
  4. Rebuild the project again as is. Check if files are modified. No files should be modified as project is rebuilt as is without any modifications
  5. Revert the test changes done and rebuild the project again. Again follow the same steps for verification as mentioned in first point.
    You can go through link which explains RPM behavior for various scenarios related to configuration changes

Pain Points

  1. prefix does not work and entire folder path should be given for every folder created by RPM
  2. changelog added to RPM was not picked up by version
  3. Multiple class binding issues related to slf4j jars.
  4. The diff between RPM lib contents and production lib contents could be more.


Problem Statement: j-units are failing

Root cause: multiple class binding issues with slf4j

Solution: add below exclusion under rpm-maven dependency




Leave a Reply

Your email address will not be published. Required fields are marked *