更新为(希望)澄清 :如果将目标定义为在给定阶段运行,是否可以在不运行所有阶段的情况下运行单个目标。换句话说,是否可以运行 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/