Maven:在一个阶段将一个插件的多个执行与其他插件执行交织 [英] Maven: Interleave multiple executions of a plugin with other plugin executions in a single phase

查看:108
本文介绍了Maven:在一个阶段将一个插件的多个执行与其他插件执行交织的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在集成前测试阶段,我需要执行以下操作:

I need to do the following in the pre-integration-test phase:

  1. sql-maven-plugin:execute
  2. jetty-maven-plugin:deploy-war
  3. sql-maven-plugin:execute

步骤1和3具有不同的配置.我尝试将1和3定义为单独的插件元素,但我相信Maven会将它们合并为一个插件定义,从而导致执行顺序为1、3、2.

Steps 1 and 3 have different configurations. I tried defining 1 and 3 as separate plugin elements, but I believe Maven just merges them into one plugin definition, resulting in an execution order of 1, 3, 2.

我需要一些方法按照上面定义的顺序执行这些操作.

I need some way to execute these in the order defined above.

推荐答案

关于Maven构建过程的简短通知:

Short notice about maven build process:

  1. 您只能在pom.xml中描述每个插件一次,重复的描述是不好的做法(容易出错).
  2. 您可以为每个插件描述多个单独的执行.
  3. 单个插件的执行(绑定到单个阶段)将按顺序运行,而与其他插件定义无关.
  4. 不同插件的执行(绑定到单个阶段)将按照pom.xml中描述的顺序运行.

考虑此语句,您可以一种简单的方法-将(1)和(3)绑定到不同的阶段.

Thinking about this statements you have a simple way - bind (1) and (3) to different phases.

我建议您绑定

  • 从(1)和(2)进入集成前测试"阶段,并且
  • (3)进入集成测试"阶段

它将解决序列问题.另请参见 maven文档中的各个阶段的完整列表.找到适合您情况的阶段.

It will solve the sequence problem. See also full list of phases in maven docs to find proper phases for your case.

如果仅从CI服务器运行此业务情景,则可以采用另一种方式.您可以通过pom.xml中的单独配置文件将构建作业配置为显式的多步骤构建:

And you have an alternative way, if you run this scenario only from CI server. You can configure build job for explicit multiple-steps build via separate profiles in pom.xml:

  • 构建二进制文件
  • 移民计划
  • 部署应用
  • 加载测试数据

它更加复杂且容易出错,所以我更喜欢第一种方法.

It is much more complex and error prone, so I prefer the first way.

这篇关于Maven:在一个阶段将一个插件的多个执行与其他插件执行交织的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆