运行时
mvn clean rpm:rpm
我收到此错误:目标org.codehaus.mojo的参数'group':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 >= 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”缺失或无效问题的主题,但没有关于“群组”丢失或无效错误的内容。
答案 0 :(得分:6)
&#34; 组&#34;参数不是通常的&#34; groupId &#34; POM。
它指的是 RPM组,它们通常在文件/usr/share/doc/rpm-$version/GROUPS
中定义。
这在plugin 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>
答案 1 :(得分: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?。
答案 2 :(得分:0)
删除执行标记。离开配置。
答案 3 :(得分:0)
在我的情况下,我需要添加...
<properties>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
</properties>