maven-antrun-plugin 只有一个目标,运行。
这允许 Maven 运行 Ant 任务。为此,必须有一个现有的项目并且 maven-antrun-plugin 必须配置其<target>标签(尽管它仍然会在没有<target>标签的情况下执行,但它不会做任何事情)。下面是maven-antrun-plugin的pom.xml的模板。
<project>
[...]
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase> <!-- a lifecycle phase --> </phase>
<configuration>
<target>
<!--
Place any Ant task here. You can add anything
you can add between <target> and </target> in a
build.xml.
-->
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>此外,您可以通过复制<execution/>部分并指定新阶段来将脚本添加到每个生命周期阶段。
最终,您可以在<target/>标记中指定一些 Ant <target/>属性。只有Ant <target/>中的depends属性没有被包装。
[...]
<configuration>
<target name="The name of the target"
if="The name of the property that must be set in order for this task"
unless="The name of the property that must NOT be set in order for this task"
description="A short description of this target's function">
<!--
Place any Ant task here. You can add anything
you can add between <target> and </target> in a
build.xml.
-->
</target>
<configuration>
[...]如果您的 ant 任务生成需要添加到构建中的其他源代码,您可以使用build-helper-maven-plugin。antrun 插件的 sourceRoot 和 testSourceRoot 选项已被弃用。
maven 可用的所有属性在目标配置中也可用。但是,您可能希望使用ant任务调用外部 Ant 构建脚本。为避免名称冲突,仅将一部分属性传递给外部 Ant 构建。这些包括在 POM 的属性部分中定义的所有属性。它还包括一些常用 Maven 属性的前缀版本。
maven.project.groupId maven.project.artifactId maven.project.name etc.
如果您要使用的 maven 属性在外部文件中不可用,则必须在调用ant之前重新定义该属性。
<property name="maven.project.url" value="${project.url}"/>
<ant antfile="build.xml"/>一些 Ant 表达式在 Maven 中有它们各自的对应项。因此,可以简单地调用相应的 Maven 表达式,而不是使用 maven-antrun-plugin 来避免不必要的开销。
| 蚂蚁表情 | Maven 表达式 |
| 内置任务 | |
| 蚂蚁 | maven-antrun-插件 |
| 蚂蚁呼叫 | maven-antrun-插件 |
| 可用的 | 简介 |
| B解压缩2 | maven-程序集插件 |
| BZip2 | maven-程序集插件 |
| 修改 | maven-程序集插件 |
| 健康)状况 | 简介 |
| 复制 | Maven 资源插件 |
| 依赖集 | maven 依赖插件 |
| 耳朵 | maven-ear-插件 |
| 筛选 | maven-resources-plugin 注意:过滤器使用 @...@ 标记,而 maven-resources-plugin 使用 $ ...标记 |
| 修复CRLF | Maven 资源插件 |
| 密钥 | maven-jar-插件 |
| G解压缩 | maven-程序集插件 |
| 压缩包 | maven-程序集插件 |
| 罐 | maven-jar-插件 |
| Javac | maven 编译器插件 |
| Javadoc/Javadoc2 | maven-javadoc-插件 |
| 加载属性 | Maven 资源插件 |
| 显现 | maven-jar-插件 |
| 财产 | Maven 资源插件 |
| 代替 | maven-resources-plugin 注意:Replace 可以指定其令牌,而 maven-resources-plugin 使用 $ ...令牌 |
| 柏油 | maven-程序集插件 |
| 解开 | maven-程序集插件 |
| 解压 | maven-程序集插件 |
| 温华 | maven-程序集插件 |
| 解压 | maven-程序集插件 |
| 战争 | Maven 战争插件 |
| 压缩 | maven-程序集插件 |
| 可选任务 | |
| 蚂蚁 | maven-antlr-插件 |
| 依靠 | maven 依赖插件 |
| EJB 任务 | maven-ejb-插件 |
| FTP | maven-deploy-plugin 注意:maven-deploy-plugin 只能部署到 FTP |
| JavaCC | maven 编译器插件 |
| JJDoc | maven 编译器插件 |
| JJ树 | maven 编译器插件 |
| JUnit | maven-surefire-插件 |
| JUnitReport | maven-surefire-report-plugin |
| 服务器部署 | Maven 部署插件 |
| 集代理 | Maven 部署插件 |
| 翻译 | maven-resources-plugin 注意:Translate 可以指定自己的标记,并且可以有不同的编码方案来读写文件。然而,maven-resources-plugin 仅使用 $ ...注释并且只有一种用于读写的编码方案 |