简体   繁体   English

使用Maven的RPM软件包

[英]RPM package using maven

I am trying to build an RPM package using the maven plugin. 我正在尝试使用Maven插件构建RPM软件包。

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. 如果我添加了未配置RPM软件包的插件配置,则RPM插件站点上的手册说该软件包标签应该是RPM,但是这似乎导致构建失败,说明该目的地是有效的。

Does anyone have any examples they could share? 有没有人可以分享任何例子?

EDIT The error is Unknown packaging: rpm 编辑错误是未知包装: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>

The only answers to this question basically say "if packaging of rpm is giving errors, just don't use it". 这个问题的唯一答案基本上是:“如果rpm的包装出现错误,请不要使用它”。 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" 有人曾经说过:“ maven并不烂,但是maven文档却很烂”

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: 首先...默认包装类型不是您可以在maven中使用的唯一包装类型,如下所示:

http://books.sonatype.com/mvnref-book/reference/writing-plugins-sect-plugins-lifecycle.html 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. 要为新包装类型定义新的生命周期,您需要在Plexus中配置LifecycleMapping组件。 In your plugin project, create a META-INF/plexus/components.xml under src/main/resources. 在您的插件项目中,在src / main / resources下创建一个META-INF / plexus / components.xml。 In components.xml add the content from Overriding the Default Lifecycle. 在components.xml中,添加“覆盖默认生命周期”中的内容。 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. 我以此为起点搜索“丛”,发现它是一个IoC(控制反转)组件框架。 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). 有点像Spring(请参阅Martin Fowler的IoC文章),它有助于“依赖注入”,也就是说,它使Java在运行时jar和类文件的标识和加载方面更加灵活,尤其是在要使用类名这样的细节时。在运行时在XML文件中配置(例如)。 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. 这是Python和Ruby真正不必担心的事情,因为它们并不像Java那样担心在编译时了解一切。 The plexus/components.xml is just such a file. plexus / components.xml就是这样的文件。 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. 此外,了解Maven插件是一个plexus组件也很有帮助-也就是说,它是要注入的依赖项-在这种情况下,该依赖项是jar,这是一个充满类文件的zip文件-类文件描述了“ Java对象”或“普通的旧Java对象”(也称为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). Maven使用的POJO是MOJO-因此所有Maven插件都是MOJO-处理Maven插件的插件是Plexus(至少在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. 因此,让我们遍历插件源代码以查看它们是否具有带有“角色提示”的rpm的components.xml文件。

...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. 我们还可以使用gihub的GIT Blame功能来查看谁记录了添加“角色提示”时的内容以及同时更改了哪些其他文件。

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

[MOJO-1249] Create rpm as primary artifact [MOJO-1249]创建rpm作为主要工件

Submitted By: Brett Okken Carlos Sanchez committed on Jan 2, 2009 提交者:Brett Okken Carlos Sanchez于2009年1月2日提交

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

3 files where changes at the same time: 3个文件同时更改:

src/main/java/org/codehaus/mojo/rpm/RPMMojo.java 的src /主/ JAVA /组织/ Codehaus的/魔力/转/ RPMMojo.java

src/main/resources/META-INF/plexus/components.xml SRC /主/资源/ META-INF /丛/ components.xml中

src/site/apt/usage.apt SRC /网站/公寓/ usage.apt

The usage.apt file is the documentation and these sections were added use.apt文件是文档,并且添加了这些部分

+
+ 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 github.com-rpm-maven-plugin-usage.apt

Since I was curious I looked up "apt markup" - 由于我很好奇,因此我查找了“ apt标记”-

www.beaglebytes.com - creating-a-document-using-apt-v01.html www.beaglebytes.com-创建-文档-使用-apt-v01.html

Almost Plain Text (APT) is a very simple yet powerful markup language. 几乎纯文本(APT)是一种非常简单但功能强大的标记语言。 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. 它特别有趣,因为它使您能够从看起来像纯文本的文档中创建整齐的HTML,RTF和其他输出格式。 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. APTconvert是一个命令行工具,可用于将APT格式转换为HTML,XHTML,PDF,PostScript,(可加载MS Word的)RTF,DocBook SGML和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). APT格式(几乎纯文本)是一种简单的标记语言(例如HTML),比可用于编写类似文章的简单文档(例如HTML)。 Unlike HTML, APT uses as few markup as possible to express the structure of the document. 与HTML不同,APT使用尽可能少的标记来表示文档的结构。 Instead, APT uses paragraph indentation. 相反,APT使用段落缩进。

hope this helps 希望这可以帮助

B rian F ennell 布莱恩·芬内尔

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. 问题在于您的包装实际上是插件结构,而不是内置的maven包类型。 Omitting the line will resolve the error. 省略该行将解决该错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM