Last updated
on 22-11-2012
at 12:00 AM


As part of my work on my JS-Test-Runner, I’ve been setting up Maven to do all my packaging for me. Deb packaging was relatively straight-forward (using the jDeb maven plugin), and happily builds on my Linux CI box and the my home Windows dev machine, but building RPMs requires a little more hackery.

The main issue is that rather than building it from scratch, as the jdeb plugin does, it uses rpmbuild directly. This unsurprisingly doesn’t exist on Windows! Your options are to hide this step under a profile and not execute it on Windows, or to install Cygwin and work from there. I went for option B:

  1. Configure RPM building in your pom (see mine for an example)
  2. Download cygwin
  3. Run the installer, and select rpm and rpm-build as packages that you’d like to have installed.
  4. Add your Cygwin bin folder (e.g. C:\cygwin\bin) to your PATH
  5. Rename the ‘system file’ (actually a symlink) at cygwin\bin\rpmbuild to cygwin\bin\rpmb
  6. Copy the script provided in this bug ticket comment to a new batch file called ‘rpmbuild.bat’ in your PATH, e.g. C:\cygwin\bin\rpmbuild.bat
  7. Make a small tweak to that file, changing the ‘rpmbuild’ at the start of the last line to ‘rpmb’

Some troubleshooting notes:

With this, I can now build JS-Test-Runner locally on my Windows box, no problemo; feel free to check out that code and try a local ‘mvn package’ to test your machine setup. RPMs will appear in [project]/target/rm/[project name]/RPMS/noarch, by default.

Many thanks for the core elements of this go to the gentlemen (or ladies) of MRPM-4, a bug ticket in the maven RPM plugin covered in comments looking at ways of doiing this. The slight tweaks to their approach are to better deal with paths, as what I could decipher from the discussion on that ticket didn’t quite hit the spot.