如何在子模块上禁用rpm-maven-plugin

时间:2014-04-18 21:00:23

标签: maven rpm-maven-plugin

我有一个包含子模块的maven项目:

/pom.xml
/child1/pom.xml
/child2.pom.xml

当我执行“maven包”时,它会创建一个/target/foo.jar。好。

当我执行“maven rpm:rpm”时,我的构建失败了,因为当它构建其中一个孩子时,它说:

[ERROR] Failed to execute goal 
org.codehaus.mojo:rpm-maven-plugin:2.1-alpha-3:attached-rpm (default-cli)
on project child1: Source location target/foo.jar does not exist

我不希望子项目执行rpm。我只希望父母转动它的神器。

documentation说:

If this goal is run on a project with modules, 
it will run the "rpm:rpm" goal on each module, rather than packaging 
the modules into a single RPM.

有没有办法解决这个问题? 我不能在执行“mvn包”时创建rpm,因为它不能在mac上运行,这是大多数人在这里开发的:只应在执行“mvn rpm:rpm”时创建rpm,或者类似的命令。

这是父母pom:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>rpm-maven-plugin</artifactId>
  <configuration>
    <name>analytics-reporting</name>
    <group>rpm</group>
    <targetVendor>amazon</targetVendor>
    <targetOS>Linux</targetOS>
    <filemode>644</filemode>
    <username>root</username>
    <groupname>root</groupname>
    <copyright>LGPL</copyright>
    <version>${rpm.version}</version>
    <release>${rpm.release}</release>
    <mappings>
      <mapping>
        <directory>/opt/inin</directory>
        <sources>
          <source>
            <location>target/analytics-reporting-engine.jar</location>
          </source>
        </sources>
      </mapping>
    </mappings>
  </configuration>
</plugin>

这是孩子:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>rpm-maven-plugin</artifactId>
  <executions>
    <execution>
      <phase>none</phase>
    </execution>
  </executions>
</plugin>

1 个答案:

答案 0 :(得分:0)

在插件的执行中,您需要指定不继承插件,如下所示:

<executions>
  <execution>
    <inherited>false</inherited>
    <id>attach-rpm</id>
    <goals>
      <goal>attached-rpm</goal>
    </goals>
  </execution>
</executions>