0

I am trying to use the rpm-maven-plugin to build an rpm. As is well known, this plugin works only on OSes that have the rpm command (RedHat, CentOS). It does not work under Windows (except perhaps with Cygwin, but that is not an option for me). Yet I code on Windows using Eclipse. This is okay, I can simply commit changes to a remote Atlassian Stash git repository and fetch it down to the RedHat server to build the rpm.

But I'd still like to be able to build the application in Eclipse just skipping the RPM part of the build.

My pom.xml has

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>rpm-maven-plugin</artifactId>
        <version>2.1.4</version>
        <executions>
            <execution>
                <id>generate-rpm</id>
                <goals>
                    <goal>rpm</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
           ...
        </configuration>
    </plugin>

I thought I might avoid the error my changing my Eclipse lifecyle-mapping metadata. (Window --> Preferences --> Maven --> Lifecycle Mapping), as described in this m2eclipse documentation

So I have the following lifecycle-mapping-metadata.xml (and yes, I did remember to update Eclipse with the new settings):

<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
  <pluginExecutions>
    <pluginExecution>
        <pluginExecutionFilter>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>rpm-maven-plugin</artifactId>
            <versionRange>[2.1.4,)</versionRange>
            <goals>
                <goal>rpm</goal>
                <goal>attached-rpm</goal>
            </goals>
        </pluginExecutionFilter>
        <action>
            <ignore />
        </action>
    </pluginExecution>
  </pluginExecutions>
</lifecycleMappingMetadata>

Yet my build is failing under Eclipse. The plugin exclusion in the lifecycle mapping is not occurring:

[ERROR] Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1.4:rpm (generate-rpm) on project icmloadtester: Unable to query for default vendor from RPM: Error while executing process. Cannot run program "rpm": CreateProcess error=2, The system cannot find the file specified -> [Help 1]

Why doesn't this mechanism work?

One possible reason for this is that Eclipse is NOT giving me the error described in the m2e document for this plugin, which is the condition that this whole lifecycle mapping business was designed to solve and perhaps this lifecycle mapping business applies to a different phase of the operation.

So how might I configure my project so that the rpm plugin execution occurs only on systems where the rpm executable exists?

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

0 Answers0