javamavenunixrpmrpm-maven-plugin

RPM package using maven


I am trying to build an RPM package using the maven plugin.

If I add the plugin configuration the RPM package is not made, the manual on the RPM plugin site says the package tag should be RPM however this seems to cause the build to fail saying that this destination is it valid.

Does anyone have any examples they could share?

EDIT The error is Unknown packaging: rpm

<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>rpm</packaging>

<profile>
            <id>local</id>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources/properties/dev</directory>
                    </resource>
                    <resource>
                        <directory>src/main/resources/txt</directory>
                    </resource>
                    <resource>
                        <directory>src/main/resources/universal</directory>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>rpm-maven-plugin</artifactId>
                        <version>2.1-alpha-3</version>
                        <extensions>true</extensions>
                        <executions>
                            <execution>
                                <id>generate-rpm</id>
                                <goals><goal>rpm</goal></goals>
                                <phase>prepare-package</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <summary>...</summary>
                            <name>...</name>
                            <version>...</version>
                            <release>...</release>
                            <vendor>...</vendor>
                            <packager>...</packager>
                            <group>Application</group>
                            <mappings>
                                <mapping>
                                    <directory>/tmp/testing</directory>
                                </mapping>
                            </mappings>
                            <!--<requires>filesystem, bash, grep</requires>-->

                            <description>
                                ...
                            </description>

                            <prepareScript>RPMScripts/prep.bash</prepareScript>
                            <preinstallScript>RPMScripts/preInstall.bash</preinstallScript>
                            <install>RPMScripts/install.bash</install>
                            <postinstall>RPMScripts/postInstall.bash</postinstall>
                            <cleanScript>RPMScripts/clean.bash</cleanScript>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.1</version>
                        <configuration>
                            <failOnError>true</failOnError>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>2.4</version>
                        <configuration>
                            <archive>
                                <manifest>
                                    <addClasspath>true</addClasspath>
                                </manifest>
                            </archive>
                        </configuration>
                    </plugin>
                    <plugin> 
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.8</version>
                        <executions>
                            <execution>
                                <phase>install</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.16</version>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>

Solution

  • The error is referencing the line :

    <packaging>rpm</packaging>
    

    At issue is the fact that your packaging is actually a plugin construct, not a built-in maven package type. Omitting the line will resolve the error.