更新(希望)澄清:如果定义一个目标在给定阶段运行,是否可以在不运行所有阶段的情况下运行单个目标.换句话说,是否可以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>
Run Code Online (Sandbox Code Playgroud)
换句话说,是否可以运行antrun:run目标(下面定义为安装阶段的一部分)而不需要依赖,生成资源,编译,测试,打包等?
不,这不对.虽然您可以配置插件(<configuration>在<plugin>元素下有一个部分)并在命令行中调用,但您无法调用特定的执行ID(因此<configuration>特定于a <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>
Run Code Online (Sandbox Code Playgroud)
并使用正确的活动配置文件进行呼叫:
mvn antrun:run -Pmy-profile
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5469 次 |
| 最近记录: |