maven-2 - 是否可以挑出并运行绑定(bind)到 Maven 阶段的特定目标?

标签 maven-2 ant

更新为(希望)澄清 :如果将目标定义为在给定阶段运行,是否可以在不运行所有阶段的情况下运行单个目标。换句话说,是否可以运行 antrun:run目标(定义为下面安装阶段的一部分)而不获取依赖项、生成资源、编译、测试、打包等?

我正在使用 antrun 插件在 package 期间创建一个 zip 文件。阶段,并在 install 期间删除和复制一些文件阶段。我了解如何运行单个 maven 插件目标,例如:mvn antrun:run .但是,有没有办法运行特定的执行目标?像 mvn antrun:run:execution-id , 或 mvn phase:antrun:run ?

基本上,如果我可以告诉 maven 除了在部署阶段运行下面定义的 ant 任务之外什么都不做,我会很好。必须等待 maven 完成所有阶段以检查部署阶段中的 ant 任务是否正常工作,这有点乏味。

<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?



不,这不对。虽然您可以配置插件(在 <configuration> 元素下使用 <plugin> 部分)并在命令行中调用,但您无法调用特定的 executionid(因此 <configuration> 特定于 <execution> ) .

在您的情况下,唯一的解决方案是在配置文件中声明 antrun 插件,比如说 my-profile , 复制以下配置部分以在此配置文件中配置插件:
<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.3</version>
  <configuration>
    <tasks>
      ... delete some files, copy some files ...
    </tasks>
  </configuration>
</plugin>

并使用正确的事件配置文件调用:
mvn antrun:run -Pmy-profile

关于maven-2 - 是否可以挑出并运行绑定(bind)到 Maven 阶段的特定目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2252359/

相关文章:

java - 如何在标准 Mac JDK6 上使用 BGGA 闭包原型(prototype)?

java - 你能告诉我,我的请求映射有什么问题吗?

ant - 如何在ant中获取用户临时目录

Ant <chdir> 任务?

java - 如何在 ant build 创建的 jar 的错误堆栈跟踪中获取源代码行号?

java - Maven : Aggregation vs. 依赖

java - Maven 2 构建 Java Web 服务?帮助

eclipse - 让groovy、maven 和eclipse 和谐共处?

java - Ant 文件复制不适用于 jdk 7

ant - 通过ant脚本运行JMockit测试时抛出异常