【问题标题】:Remove one goal from plugin execution from parent pom从父 pom 的插件执行中删除一个目标
【发布时间】:2019-09-13 08:40:34
【问题描述】:

最近我们将 maven 版本更改为 3.5.4 根据https://issues.apache.org/jira/browse/MNG-5940

maven-source-plugin jar 目标已更改为 Maven Super POM 中的 jar-no-fork

我们有公司主 pom:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>3.0.1</version>
    <executions>
        <execution>
            <id>attach-sources</id>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

哪一个我不能改变。 加上 maven super pom 在有效的 pom 我得到了

<plugin>
  <artifactId>maven-source-plugin</artifactId>
  <version>3.0.1</version>
  <executions>
    <execution>
      <id>attach-sources</id>
      <goals>
        <goal>jar-no-fork</goal>
        <goal>jar</goal>
      </goals>
    </execution>
  </executions>
  <inherited>true</inherited>
</plugin>

在发布期间会生成两次源(一个文件覆盖第二个文件),但在部署到 Artifactory 时出现错误,因为没有权限覆盖工件。

我可以配置一些我的 pom 来禁用插件的一个目标吗?

【问题讨论】:

  • 你检查this了吗?
  • 是的,我做到了,我不想禁用整个插件,但只有一个目标
  • 修复你的公司 pom ...

标签: java maven


【解决方案1】:

您需要从父 pom 中删除执行(删除默认阶段就足够了)并添加具有新目标的新执行:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-source-plugin</artifactId>
  <version>3.0.1</version>
  <executions>
    <execution>
      <id>attach-sources</id>
      <phase/>
    </execution>
    <execution>
      <id>custom-attach-sources</id>
      <goals>
        <goal>jar-no-fork</goal>
      </goals>
    </execution>
  </executions>
  <inherited>true</inherited>
</plugin>

【讨论】:

  • 问题是我可以在不改变父 pom 的情况下做到吗?
  • 答案是,将 sn-p 放入您孩子的 pom 中!
猜你喜欢
  • 2016-01-19
  • 1970-01-01
  • 2018-04-12
  • 2013-09-09
  • 2017-01-02
  • 1970-01-01
  • 2011-06-17
  • 2017-02-22
  • 1970-01-01
相关资源
最近更新 更多