如何覆盖默认的 maven-install-plugin 行为?

2024-03-30

我需要自定义工件安装,并且无法弄清楚如何覆盖默认工件(来自默认的 Maven 生命周期)。所以我的问题是:

如何在我的 pom.xml 中配置 Maven 安装插件,以便它不执行默认安装并仅执行我的自定义安装文件目标?

我试过没有 id 和默认安装 http://maven.apache.org/guides/mini/guide-default-execution-ids.htmlid 并没有帮助。

Update:从提供的答案来看 - 这对我不起作用(我在日志中看到两次安装尝试)。

<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-install-plugin</artifactId>
      <executions>
        <execution>
          <id>default-install</id>
          <phase>none</phase>
        </execution>
      </executions>
    </plugin>
  </plugins>
</pluginManagement>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.3.1</version>
    <executions>
      <execution>
        <id>install-jar-lib</id>
        <goals>
          <goal>install-file</goal>
        </goals>
        <phase>install</phase>
        <configuration>
          <file>${project.build.directory}/${project.build.finalName}.jar</file>
          <generatePom>false</generatePom>
          <pomFile>pom.xml</pomFile>
          <packaging>jar</packaging>
          <version>${unicorn.version}</version>
        </configuration>
      </execution>
    </executions>
  </plugin>

禁用maven-install-plugin:

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>none</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </pluginManagement>
</build>

以及执行您的自定义安装目标:

<build>
  <plugins>
    <plugin>
      <groupId>yourGroupId</groupId>
      <artifactId>yourArtifactId</artifactId>
      <executions>
        <execution>
          <id>custom-install</id>
          <phase>install</phase>
          <goals>
            <goal>yourGoal</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何覆盖默认的 maven-install-plugin 行为? 的相关文章

随机推荐

  • 在 ggplot 或lattice 中利用 Surv 对象

    有人知道如何利用 ggplot 或lattice 进行生存分析吗 制作网格或类似面的生存图会很好 所以最后我尝试了一下 找到了卡普兰 迈耶图的解决方案 对于将列表元素放入数据框中的混乱代码 我深表歉意 但我无法找到其他方法 注意 它仅适用于
  • Jenkins Git 插件包含不工作的区域

    我无法使用 Git 插件在 Jenkins 中使用 包含区域 功能 我希望仅在 他的 目录发生更改时才构建作业 示例 项目 mytool 仅应在以下内容发生更改时构建GIT ROOT tools mytool 我在包含的区域字段中尝试了几种
  • 删除默认标题栏

    如何删除 Android 应用程序中默认的顶部标题栏 灰色的你好 Android 吧 删除标题栏非常简单 只需将 android theme 属性添加到 AndroidManifest xml 中即可
  • ICollection 的简单现有实现

    有没有简单的实现ICollection
  • AngularJS 指令中的 locals 代表什么

    AFAIK 这没有记录 但我在角度源中发现locals指令示例中的属性 angular module transclude directive pane function return restrict E transclude true
  • 如何使用已安装的斜纹登录网站?

    我刚刚安装成功TWILL https web archive org web 20180904160747 http twill idyll org 80 在 StackOverflow 一位非常支持的成员的帮助下在我的计算机上 你可以查看
  • 通用协方差和转换为 SuperType

    我有一个面向对象的问题 我认为它可以与通用协方差联系起来 我正在尝试构建一个模块化系统来导入不同类型的记录 模块包含常用方法 SalesModule 包含处理特定逻辑的函数 public interface IImportable void
  • 克隆 jQuery UI 日期选择器时出现问题

    我有一个 div 其中有一个日期选择器 我用这样的东西来克隆它 mydiv someDiv works fine so far mydiv find input datefield datepicker clone without the
  • C#BackgroundWorker 的文化

    我想为我的整个应用程序设置文化 我尝试了以下操作 Thread CurrentThread CurrentCulture CultureInfo CreateSpecificCulture wantedCulture Thread Curr
  • 浏览器之间盒子模型的不同解释

    我注意到浏览器之间在宽度方面存在差异TH标签被解释 特别是宽度计算中是否包含填充 我正在构建一个可重用的库 用于快速生成表格和设计表格样式 当然 对于表格数据 这意味着我可以完全控制我生成的代码 但我需要实际解决问题而不是为特定实例寻找黑客
  • Qt 和 CMake 因重复符号而失败

    我的 c qt 项目中有 3 个文件 并且我正在使用 CMake 我正在尝试编译它这里有一些代码 CMakeLists 包含 cmake minimum required VERSION 3 8 project untitled set C
  • Apache Commons Lang 2 与 3

    在我的应用程序中 我使用 apache commons Lang v 3 所需的图书馆给我一个 java lang ClassNotFoundException org apache commons lang StringUtils com
  • 在 Rails 中添加与 simple_form、nested_form 和 Twitter Bootstrap 内联的控件

    我正在使用 simple form nested form 和 Twitter Bootstrap 并尝试将nested form 中的 删除链接 与对象放在同一行 现在看起来像这样 http grab by eKDS http grab
  • 安装适用于 Python 的 cx_Oracle

    在 Debian 5 上 我一直在尝试为 python 安装 cx oracle 模块 但没有成功 首先 我安装了 oracle xe client 及其依赖项 按照以下链接中的教程here http le gall net pierric
  • MSXML 哪个版本开始支持解析 XML 1.1?

    如果我使用 MSXML6 dll 解析 XML 1 1 我将收到此错误 0xC00CE57F MSG E INVALID VERSION 版本号无效 XML 1 1 最初发布于 2004 年 2 月 4 日 令我惊讶的是 MSXML6 dl
  • TDD 新手:是否有带有测试的示例应用程序来展示如何进行 TDD?

    我真的很想进入 TDD 开发 但我不知道从哪里开始 我认为 查看代码并了解他们如何编写测试并使类可测试 这样我会更容易消化并开始使用自己 有谁知道任何示例或小型开源C 包含单元测试的应用程序 对于沙卡尔佩什来说 我会推荐 ObjectMen
  • with() 语句从 opencv 中的 VideoCapture 读取?

    我喜欢使用 with 语句来访问文件和数据库连接 因为如果出现错误或文件关闭 它会自动为我断开连接 f open file txt r for i in f print i f close versus with open file txt
  • 在 bash 中读取以空格分隔的文件,不会导致空字段崩溃

    我正在尝试在 bash 中读取多行制表符分隔的文件 格式要求为空字段 不幸的是 外壳正在将彼此相邻的字段分隔符折叠在一起 如下所示 IFS t read one two three lt lt lt one t tthree printf
  • Fletchers16 校验和适合小数据吗?

    使用直接实施维基百科弗莱彻的校验和 https en wikipedia org wiki Fletcher s checksum对于 BCA 和 CAB 以及 BAC 和 ACB 等数据 我们得到相同的校验和 这是预期的吗 Fletche
  • 如何覆盖默认的 maven-install-plugin 行为?

    我需要自定义工件安装 并且无法弄清楚如何覆盖默认工件 来自默认的 Maven 生命周期 所以我的问题是 如何在我的 pom xml 中配置 Maven 安装插件 以便它不执行默认安装并仅执行我的自定义安装文件目标 我试过没有 id 和默认安