是否有可能挑出并运行绑定到一个Maven的阶段一个具体的目标? [英] Is it possible to single out and run a specific goal bound to a maven phase?

查看:97
本文介绍了是否有可能挑出并运行绑定到一个Maven的阶段一个具体的目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新(希望)澄清:如果目标被定义在某一阶段的运行,才有可能不运行直通各阶段运行各个目标。换句话说,才有可能运行 antrun:没有得到相关性运行目标(其定义为下面的安装阶段的一部分),生成资源,编译,测试,包装等?

我使用antrun插件创建在阶段的zip文件,并删除并在安装阶段。我明白如何运行单个的Maven插件目标,例如: MVN antrun:运行。但是,有没有一种方式来运行特定执行的目标是什么?类似 MVN antrun:运行:执行-ID MVN阶段:antrun:运行

基本上,我会很好,如果我可以告诉Maven来别的什么也不要做运行部署阶段内下面定义的Ant任务,例如。这是一种单调乏味不必等待行家去THRU所有阶段只是为了检查是否在部署阶段蚂蚁任务是否工作正常。

 <&执行GT;
  <! - 创建zip文件 - >
  <执行与GT;
    <&ID GT;创建拉链< / ID>
    <阶段>包装及LT; /阶段>
    <结构>
      <任务和GT;
    ...创建zip ...
      < /任务>
    < /结构>
    <目标>
      <&目标GT;运行< /目标>
    < /目标>
      < /执行>
  <! - 做一些其他的东西 - >
  <执行与GT;
    <&ID GT;复制文件< / ID>
    <阶段>安装与LT; /阶段>
    <结构>
      <任务和GT;
    ...删除一些文件,拷贝一些文件...
      < /任务>
    < /结构>
    <目标>
      <&目标GT;运行< /目标>
    < /目标>
      < /执行>
    < /处决>


解决方案

  

在换言之,才有可能以运行antrun:没有得到依赖运行的目标(其被定义为下面的安装阶段的一部分),生成资源,编译,测试,封装等


没有事实并非如此。虽然您可以配置一个插件(以<结构> ℃在部分;插件> 元素)和呼叫在命令行上,你不能调用一个特定的流程id(并因此​​<结构> 特定于<执行> )。

在你的情况下,唯一的解决办法是宣布antrun插件在配置文件中,假设我的知名度,重复配置的以下部分配置插件在此配置文件:

 <&插件GT;
  <&的artifactId GT;的maven-antrun-插件< / artifactId的>
  <&版GT; 1.3< /版本>
  <结构>
    <任务和GT;
      ...删除一些文件,拷贝一些文件...
    < /任务>
  < /结构>
< /插件>

和用正确的活动配置文件称:

  MVN antrun:运行-Pmy瞩目

Updated to (hopefully) clarify: If a goal is defined to run during a given phase, is it possible to run the individual goal without running thru all phases. In other words would it be possible to run the antrun:run goal (which is defined as part of the install phase below) without getting dependencies, generate-resources, compiling, testing, package, etc?

I'm using the antrun plugin to create a zip file during the package phase and to delete and copy some files during the install phase. I understand how to run single maven plugin goals, for example: mvn antrun:run. However, is there a way to run a specific execution's goal? Something like mvn antrun:run:execution-id, or mvn phase:antrun:run?

Basically, I'd be nice if I can tell maven to do nothing else but run the ant tasks defined below inside the deploy phase, for example. It's kind of tedious having to wait for maven to go thru all the phases just to check if the ant tasks in the deploy phase are working correctly.

<executions>
  <!-- create zip file -->
  <execution>
    <id>create-zip</id>
    <phase>package</phase>
    <configuration>
      <tasks>
    ...create zip...
      </tasks>
    </configuration>
    <goals>
      <goal>run</goal>
    </goals>
      </execution>
  <!-- do some other stuff  -->
  <execution>
    <id>copy-files</id>
    <phase>install</phase>
    <configuration>
      <tasks>
    ...delete some files, copy some files ...
      </tasks>
    </configuration>
    <goals>
      <goal>run</goal>
    </goals>
      </execution>
    </executions>

解决方案

In other words would it be possible to run the antrun:run goal (which is defined as part of the install phase below) without getting dependencies, generate-resources, compiling, testing, package, etc?

No it's not. While you can configure a plugin (with a <configuration> section under the <plugin> element) and call in on the command line, you can't invoke a specific executionid (and consequently the <configuration> specific to an <execution>).

The only solution in your case would be to declare the antrun plugin in a profile, let's say my-profile, to duplicate the following part of the configuration to configure the plugin in this profile:

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.3</version>
  <configuration>
    <tasks>
      ... delete some files, copy some files ...
    </tasks>
  </configuration>
</plugin>

and to call with the right active profile:

mvn antrun:run -Pmy-profile

这篇关于是否有可能挑出并运行绑定到一个Maven的阶段一个具体的目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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