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>
有帮助吗?

解决方案 2

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.

其他提示

The only answers to this question basically say "if packaging of rpm is giving errors, just don't use it". I am running into the exact same thing, so I will try to shed some more light on the issue.

Someone once said "maven doesn't suck, but maven documentation does"

Here is what I have found -

First... the default packaging types aren't the only packaging types you can use in maven, as stated here:

http://books.sonatype.com/mvnref-book/reference/writing-plugins-sect-plugins-lifecycle.html

To define a new lifecycle for a new packaging type, youbll need to configure a LifecycleMapping component in Plexus. In your plugin project, create a META-INF/plexus/components.xml under src/main/resources. In components.xml add the content from Overriding the Default Lifecycle. Set the name of the packaging type under role-hint, and the set of phases containing the coordinates of the goals to bind (omit the version). Multiple goals can be associated with a phase using a comma delimited list.

Using this as a starting point I searched for "plexus" and discovered that is a IoC (Inversion of Control) Component Framework. A bit like Spring (read Martin Fowler's IoC Article) it helps with "dependency injection" which is to say it makes java more flexible about runtime jar and class file identification and loading, especially if such details as the name of the classes are to be configured at runtime in XML files (for example). Which is something Python and Ruby don't really have to worry about because they are not so concerned with knowing everything at compile time as Java is. The plexus/components.xml is just such a file. Also it helps to know that a Maven Plugin is a plexus component - that is, it is a dependency to be injected - in this case that dependency is a jar, which is a zip file full of class files - a class file describes a "java object" or a "plain old java object" also called a POJO. A POJO for use by Maven is a MOJO - so all Maven plug-ins are MOJOs - and the thing which handles plugging in of the plug-in for Maven is Plexus (at least in Maven 2). So lets hunt through the plug-in source code to see if they have a components.xml file with a "role-hint" of rpm.

...and they do... ("use the source, Luke")

we can also use gihub's GIT Blame feature to see who documented what when the "role-hint" was added and what other files were changed at the same time.

github.com - rpm-maven-plugin - blame - 0efd27d3beb64c291b960731fe1bdbbb5dbd938e - src/main/resources/META-INF/plexus/components.xml

[MOJO-1249] Create rpm as primary artifact

Submitted By: Brett Okken Carlos Sanchez committed on Jan 2, 2009

github.com - rpm-maven-plugin - commit - fb9bc1ae7488dc0fa6853cdd874fc907c628122d

3 files where changes at the same time:

src/main/java/org/codehaus/mojo/rpm/RPMMojo.java

src/main/resources/META-INF/plexus/components.xml

src/site/apt/usage.apt

The usage.apt file is the documentation and these sections were added

+
+ The packaging value should be set to "<<<rpm>>>".
++-------+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
+ <modelVersion>4.0.0</modelVersion>
+ ...
+ <packaging>rpm</packaging>
+ ...
+</project>
++-------+
+
+ The extensions tag for this plugin should be marked true.
+
++-------+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rpm-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ ...
+ </plugin>
+ </plugins>
+ </build>
++-------+

The whole documentation file is:

github.com - rpm-maven-plugin - usage.apt

Since I was curious I looked up "apt markup" -

www.beaglebytes.com - creating-a-document-using-apt-v01.html

Almost Plain Text (APT) is a very simple yet powerful markup language. It is particularly interesting because it enables you to create neatly formatted HTML, RTF, and other output formats from a document that appears to be in plain text. As the documentation says:

APTconvert is a command-line tool that can be used to convert the APT format to HTML, XHTML, PDF, PostScript, (MS Word loadable) RTF, DocBook SGML and DocBook XML.

The APT format (Almost Plain Text) is a simple markup language (like HTML) than can be used to write simple article-like documents (like HTML). Unlike HTML, APT uses as few markup as possible to express the structure of the document. Instead, APT uses paragraph indentation.

hope this helps

B r i a n F e n n e l l

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top