Terri Simon Terri Simon - 1 year ago 133
Bash Question

Can I use a variable in a Maven profile as a parameter for a postinstallScriptlet with the RPM plugin?

I am updating some RPMs that were originally done with spec files to use the Maven RPM plugin. The original setup is rather convoluted, but includes a "common" project which is used by four other projects. The spec files were in that common project, as well as shell scripts that used parameters to specify certain things (let's say, to distinguish between Project A and Project B when making folder names). I want to make profiles that handle the parameter that were passed into the shell scripts. Those scripts handle a lot of things that I don't want to rework if I don't have to. Is there a way to use values that I set in the profile to act as the shell script parameters, providing that I use that shell script (minimally modified) as the postInstallScriptlet.

This is all on Linux (Centos 6).

So, the profile would look something like this:


The script file would have something like this:


How can I get those two things to work together?

Answer Source

After further hunting and experimentation, I've been able to resolve this. There are two questions which describe how to do this at a higher level. Below the links, I will show what I did, in hopes of making this a useful example.


and using-maven-rpm-plugin-how-do-i-to-replace-text-in-files-similar-to-the-assembly

The plugin section is:

                  <!-- note that this will process all files in this directory -->                  

Then, in the profile:

      <MODULE>Project A</MODULE>
      <!-- and more -->

And in the postinstallScriptlet file:


This results in the file being copied into the ${basedir}/bin directory with all the variable substitutions being made. This is exactly what I needed, so I hope this helps someone else.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download