更改Maven插件执行的顺序 [英] Changing the order of maven plugin execution

查看:351
本文介绍了更改Maven插件执行的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Maven的新手.我想更改Maven插件的执行顺序.

I am new to maven. I would like to change the order of maven plug-in execution.

在我的pom.xml中,我有maven-assembly-plugin和maven-ant-plugin.我已经使用maven-assembly-plugin创建zip文件,并使用maven-ant-plugin将zip文件从目标复制到某些其他目录.当我运行pom.xml时,触发了maven-ant-插件,并最终找到了zip文件,但出现错误,提示找不到zip文件.请建议我在该maven-ant-plugin需要运行之后如何首先运行maven-assembly-plugin的方式,以便它将zip文件复制到相应的目录中.

In my pom.xml, I have maven-assembly-plugin and maven-ant-plugin .I have used maven-assembly-plugin for creating zip file and maven-ant-plugin for copying the zip file from target to some other directory. When I run pom.xml, maven-ant- plugin got triggered and looking for zip file finally I got the error saying zip file not found. Please suggest me the way how to run maven-assembly-plugin first after that maven-ant-plugin needs to run so that it will copy zip file to the corresponding directory.

推荐答案

由于您说您是Maven的新手,所以... Maven构建是按顺序执行的一系列阶段.这些阶段由生命周期确定,您的项目基于其包装.

Since you say you are very new to Maven....Maven builds are executions of an ordered series of phases. These phases are determined by the lifecycle that is appropriate to your project based on its packaging.

因此,控制何时插件的目标由

Therefore, you control when a plugin's goal is executed by binding it to a particular phase.

希望有帮助.

编辑:此外,自Maven 3.0.3起,对于绑定到同一阶段的两个插件,执行顺序与您<定义它们.例如:

Also, since Maven 3.0.3, for two plugins bound to the same phase, the order of execution is the same as the order in which you define them. For example:

<plugin>
  <artifactId>maven-plugin-1</artifactId>
  <version>1.0</version>
  <executions>
    <execution>
      <phase>process-resources</phase>
      ...
    </execution>
  </executions>
</plugin> 
<plugin>
  <artifactId>maven-plugin-2</artifactId>
  <version>1.0</version>
  <executions>
    <execution>
      <phase>process-resources</phase>
      ...
    </execution>
  </executions>
</plugin> 
<plugin>
  <artifactId>maven-plugin-3</artifactId>
  <version>1.0</version>
  <executions>
    <execution>
      <phase>generate-resources</phase>
      ...
    </execution>
  </executions>
</plugin>

在上述情况下,执行顺序为:

In the above instance, the execution order would be:

  1. maven-plugin-3(生成资源)
  2. maven-plugin-1(流程资源)
  3. maven-plugin-2(流程资源)

这篇关于更改Maven插件执行的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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