【问题标题】:The parameters 'group' for goal org.codehaus.mojo:rpm-maven-plugin:2.1.5:rpm are missing or invalid目标 org.codehaus.mojo:rpm-maven-plugin:2.1.5:rpm 的参数“组”丢失或无效
【发布时间】:2016-09-18 13:28:24
【问题描述】:

运行时

mvn clean rpm:rpm 

我收到此错误:目标 org.codehaus.mojo:rpm-maven-plugin:2.1.5:rpm 的参数“组”丢失或无效

我的父母 pom.xml :

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.brewspberry</groupId>
<artifactId>brewspberry-rpm-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>brewspberry-rpm-parent</name>
<description>brewspberry-rpm-parent</description>
<packaging>pom</packaging>

<properties>
    <rpm.install.basedir>/opt/tomcat</rpm.install.basedir>
    <rpm.install.webapps>${rpm.install.basedir}/webapps</rpm.install.webapps>
    <rpm.install.config>${rpm.install.basedir}/lib</rpm.install.config>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.build.group>Internet</project.build.group>
</properties>

<modules>
    <module>brewspberry-regulator-algo</module>
    <module>brewspberry-api</module>
    <module>brewspberry-core</module>
    <module>brewspberry-jbatches</module>
    <module>brewspberry-webapp</module>
</modules>
<profiles>
    <profile>
        <id>rpm-build</id>
        <activation>
            <property>
                <name>build-rpm</name>
            </property>
        </activation>

        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>rpm-maven-plugin</artifactId>
                    <version>2.1</version>
                    <extensions>true</extensions>

                    <executions>
                        <execution>
                            <goals>
                                <goal>rpm</goal>
                            </goals>
                            <configuration>
                                <classifier>${rpm.classifier}</classifier>
                                <copyright>Biologeek</copyright>
                                <icon>src/main/resources/img/icon.png</icon>
                                <distribution>Brewspberry</distribution>
                                <targetOS>linux</targetOS>
                                <needarch>noarch</needarch>
                                <group>Internet</group>
                                <packager>${user.name}</packager>
                                <changelogFile>CHANGELOG</changelogFile>
                                <defaultDirmode>540</defaultDirmode>
                                <defaultFilemode>440</defaultFilemode>
                                <defaultUsername>tomcat</defaultUsername>
                                <defaultGroupname>tomcat</defaultGroupname>

                                <properties>
                                    <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
                                    <project.build.group>net.brewspberry</project.build.group>
                                </properties>

                                <requires>
                                    <require>apache-tomcat &gt;= 8.0.24</require>
                                </requires>
                                <mappings>
                                    <mapping>
                                        <directory>${rpm.install.webapps}/brewspberry-api</directory>
                                        <sources>
                                            <source>
                                                <location>./brewspberry-api/target/brewspberry-api/target/brewspberry-api-0.1.0-SNAPSHOT.war</location>
                                            </source>
                                        </sources>
                                    </mapping>

                                    <mapping>
                                        <directory>${rpm.install.webapps}/brewspberry-webapp</directory>
                                        <sources>
                                            <source>
                                                <location>./brewspberry-webapp/target/brewspberry-webapp/target/brewspberry-api-0.1.0-SNAPSHOT.war</location>
                                            </source>

                                        </sources>
                                    </mapping>
                                </mappings>
                                <postinstallScriptlet>
                                    <scriptFile>
                                        src/main/resources/rpm/postinstall.sh
                                    </scriptFile>
                                    <fileEncoding>utf-8</fileEncoding>
                                </postinstallScriptlet>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>

    </profile>
</profiles>

我尝试通过添加或删除 project.build.group 来修改它,但仍然不起作用。

我总是收到这个错误。

发现了几个关于“sourceEncoding”缺失或无效问题的主题,但没有发现“group”缺失或无效错误。

【问题讨论】:

  • 你有没有弄明白这个?我也遇到了同样的错误
  • 没有仍然得到错误。也许我应该更改 maven-rpm-plugin 版本并重新测试。你呢?

标签: java maven pom.xml


【解决方案1】:

group”参数不是 POM 常用的“groupId”。 它指的是通常在文件/usr/share/doc/rpm-$version/GROUPS 中定义的一组RPMplugin docs 中提到了这一点。 您需要使用正确的组配置 RPM 插件;像这样:


<plugins >
...
    <plugin>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>rpm-maven-plugin</artifactId>
       <version>2.1.5</version>
       <configuration>
           <group>Development/Tools</group>
       </configuration>
    </plugin>
...
</plugins>

【讨论】:

  • 嗨尼克。简单地说,我的解决方案是正确的。问题是 maven 抱怨,因为缺少强制参数,并且我提供的文档的链接告诉您确切需要如何设置该参数。混淆的原因是有一个名为 groupId 的 fundamental maven param 和一个名为 group 的(很少使用的)rpms 插件中的不相关值。此外,我尝试了投票最多的答案,但并没有解决问题。我的做到了。
【解决方案2】:

当您在某个 pom 文件中指定 rpm 插件及其配置并尝试从父目录构建时,会发生此错误。在这种情况下,maven 将在所有项目上运行目标rpm:rpm,因此 rpm 插件也将应用于所有可能没有配置 rpm 插件的项目。

解决办法:

将此插件移出以分离子模块。

在您的情况下,创建例如rpm-package 具有整个配置文件的模块:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>net.brewspberry</groupId>
     <!-- I would rename it, parent is not rpm anymore -->
     <artifactId>brewspberry-rpm-parent</artifactId>
     <version>0.1.0-SNAPSHOT</version>
   </parent>
   <artifactId>rpm-package</artifactId>
   ...
   <!-- move entire block "profiles" here -->
   <profiles>
     <profile>
       <id>rpm-build</id>
       ...
     </profile>
   </profiles>
 </project>

在你的父 pom.xml 中:

<modules>
  ...
  <module>rpm-package</module>
</modules>

不要忘记更新映射的源路径。

现在你可以运行了:

mvn clean package

此外,如果您也在 Windows 上构建,请参阅 How do I make this plugin run only on non-Windows platforms?

【讨论】:

  • 你能详细说明你的答案吗?我们应该将插件定义作为配置文件的一部分吗?
  • @prash,激活配置文件后,插件仍将应用于所有子模块,您将收到相同的错误。您可以将插件移动到单独的子模块,它会做自己的单一工作 - 构建 rpm 包。例如,仅当您指定某些选项或在特定平台上构建时,才能使用配置文件构建 rpm。
【解决方案3】:

就我而言,我需要添加...

<properties>
    <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
</properties>

【讨论】:

    【解决方案4】:

    您可能需要激活个人资料

    mvn -P rpm-build rpm:rpm
    

    【讨论】:

      【解决方案5】:

      删除执行标签。只需保留配置即可。

      【讨论】:

        猜你喜欢
        • 2015-08-11
        • 2019-08-16
        • 2012-12-12
        • 2013-11-19
        • 1970-01-01
        • 2020-08-16
        • 2017-09-19
        • 2019-05-01
        相关资源
        最近更新 更多