【问题标题】:how to disable rpm-maven-plugin on sub modules如何在子模块上禁用 rpm-maven-plugin
【发布时间】:2014-06-03 10:38:44
【问题描述】:

我有一个包含子模块的 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。我只希望父级 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 package”时创建 rpm,因为它在 mac 上不起作用,这是大多数人在这里开发的:rpm 只能在执行“mvn 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>

【问题讨论】:

  • 查看这个答案:stackoverflow.com/a/14210506/1089062。把它放在你的孩子 poms 里。
  • 感谢您的信息,但它不起作用。对我来说,它应该工作是完全有道理的,但它没有,我不明白为什么。我将使用父 pom 和子 pom 更新我的原始问题。

标签: maven rpm-maven-plugin


【解决方案1】:

有一个属性。 https://www.mojohaus.org/rpm-maven-plugin/rpm-mojo.html#disabled

<rpm.disabled>true</rpm.disabled>

【讨论】:

    【解决方案2】:

    在插件的执行中你需要指定不继承插件,像这样:

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

    【讨论】:

      猜你喜欢
      • 2014-10-07
      • 2014-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-25
      • 2013-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多