以下引用官方的介绍http://maven.apache.org/plugins/maven-antrun-plugin/

一、什么是maven-antrun-plugin?

该插件提供从Maven内运行Ant任务的功能。您甚至可以将您的Ant脚本嵌入POM!

这个插件不是提供污染POM的手段意图,因此它鼓励所有Ant任务移动到build.xml文件并使用Ant的POM的<ant/> task调用它(或者说所有在build.xml文件的Ant任务移动到POM中,并使用<ant/> task调用它)。

这个插件的主要目的之一是方便从Ant基础项目迁移到Maven。某些项目可能无法迁移,因为它们依赖于默认情况下Maven不提供的自定义构建功能。

二、坐标

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>

三、简单使用,参考官网http://maven.apache.org/plugins/maven-antrun-plugin/usage.html

<project>
[...]
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase> <!-- Maven的生命周期阶段 --> </phase>
<configuration>
<target> <!--
将任务Ant任务放在这里,还可以在这里添加一个build.xml文件
--> </target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>

当然,如上所示的配置其实还少了几个属性,不过这不影响运行,因为默认是继承超级POM的。

提示:

1、Maven的生命周期阶段参考:http://www.cnblogs.com/EasonJim/p/6816340.html

2、在<target>中的标签只有搞过Ant集成的才会比较熟悉,如果想要使用其中的标签,参考官方提供的文档:http://ant.apache.org/manual/tasksoverview.html

以下将展示官方实际项目上的POM:

http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html

http://maven.apache.org/plugins/maven-antrun-plugin/examples/tasksAttributes.html

http://maven.apache.org/plugins/maven-antrun-plugin/examples/customTasks.html

<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>my-test-app</artifactId>
<groupId>my-test-group</groupId>
<version>1.0-SNAPSHOT</version> <build>
<plugins> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/> <echo message="compile classpath: ${compile_classpath}"/>
<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="test classpath: ${test_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

注意:<id>为唯一的标识,可以是任意。

四、Ant插件只有一个目标(goal)

既:antrun:run,参考:http://maven.apache.org/plugins/maven-antrun-plugin/run-mojo.html

五、其它Ant集成例子

参考:http://maven.apache.org/plugins/maven-antrun-plugin/tasks/tasks.html

总结:

1、简单的说这个Ant插件就是为了方便把之前在Ant集成的任务迁移到Maven中去、

2、在Maven中的<target>中可以很方便的使用Ant的标签。

3、通过<phase>可以很方便的指定Maven的生命周期。并且指定生命周期之后,可以在生命周期运行时直接触发<target>中的任务。

Maven插件maven-antrun-plugin的使用的更多相关文章

  1. groovy入门(2-1)Groovy的Maven插件安装:Plugin execution not covered by lifecycle configuration

    参考链接:http://www.cnblogs.com/rightmin/p/4945797.html 1.引入groovy的jar包 2.引入groovy编译插件 3.遇到问题 Plugin exe ...

  2. Maven学习(十六)-----Maven插件

    Maven插件 Maven 是一个执行插件的框架,每一个任务实际上是由插件完成的.Maven 插件通常用于: 创建 jar 文件 创建 war 文件 编译代码文件 进行代码单元测试 创建项目文档 创建 ...

  3. Java-Maven-Runoob:Maven 插件

    ylbtech-Java-Maven-Runoob:Maven 插件 1.返回顶部 1. Maven 插件 Maven 有以下三个标准的生命周期: clean:项目清理的处理 default(或 bu ...

  4. 【mybatis源码学习】利用maven插件自动生成mybatis代码

    [一]在要生成代码的项目模块的pom.xml文件中添加maven插件 <!--mybatis代码生成器--> <plugin> <groupId>org.mybat ...

  5. 使用maven插件dockerfile-maven-plugin生成Docker镜像并推送到镜像仓库

    1.引入maven插件 <build> <plugins> <plugin> <groupId>com.spotify</groupId> ...

  6. maven课程 项目管理利器-maven 3-4 eclipse安装maven插件和新建maven项目

    本节主要讲了两个主要内容, 1       eclipse安装maven插件 2 新建maven项目 3 本人实操 1       eclipse安装maven插件 eclipse4.0以上和myec ...

  7. eclipse插件——maven

    项目开发中遇到的问题 都是同样的代码,为什么在我的机器上可以编译执行,而在他的机器上就不行? 为什么在我的机器上可以正常打包,而配置管理员却打不出来? 项目组加入了新的人员,我要给他说明编译环境如何设 ...

  8. [Maven]Apache Maven 入门篇

    作者:George Ma 上 写这个 maven 的入门篇是因为之前在一个开发者会的动手实验中发现挺多人对于 maven 不是那么了解,所以就有了这个想法.这个入门篇分上下两篇.本文着重动手,用 ma ...

  9. Spring Boot的Maven插件Spring Boot Maven plugin详解

    Spring Boot的Maven插件(Spring Boot Maven plugin)能够以Maven的方式为应用提供Spring Boot的支持,即为Spring Boot应用提供了执行Mave ...

  10. Maven版本管理-Maven Release Plugin插件

    一.什么是版本管理 首先,这里说的版本管理(version management)不是指版本控制(version control),但是本文假设你拥有基本的版本控制的知识,了解subversion的基 ...

随机推荐

  1. 【LeetCode】Linked List Cycle II(环形链表 II)

    这是LeetCode里的第142道题. 题目要求: 给定一个链表,返回链表开始入环的第一个节点. 如果链表无环,则返回 null. 说明:不允许修改给定的链表. 进阶:你是否可以不用额外空间解决此题? ...

  2. Latex:插入伪代码

    *本文属于转载. *转载链接:https://blog.csdn.net/lwb102063/article/details/53046265 目录 clrscode algorithm algori ...

  3. bash实例-参数/函数/统计IP

    1.写一个脚本getinterface.sh,脚本可以接受参数(i,I,a),完成以下任务:   (1)使用以下形式:getinterface.sh [-i interface|-I IP|-a]  ...

  4. golang连接orcale

    使用glang有一段时间了,最开始其实并不太喜欢他的语法,但是后来熟悉之后发现用起来还挺爽的.之前数据库一直使用mysql,连接起来没有什么问题,github上有很多完善的驱动,所以以为连接其他数据库 ...

  5. <node>……express的中间件……//

    Express是一个基于Node.js平台的web应用开发框架,在Node.js基础之上扩展了web应用开发所需要的基础功能,从而使得我们开发Web应用更加方便.更加快捷. 中间件是什么? 中间件函数 ...

  6. Just a test

  7. df和du显示的磁盘空间使用情况不一致问题

    背景介绍: dba同事删除了mysql /datao目录下的文件,通过du –sh查看空间使用700G,df -h查看空间使用1T,没有重启mysql服务. 另一个表现出du与df命令不同之处的例子如 ...

  8. Thinkphp5.1源码阅读

    主要流程 1 \public\index.php require __DIR__ . '/../thinkphp/start.php'; \thinkphp\start.php require __D ...

  9. 在Notepad++里配置python环境

    首先在语言里选择Python 然后点击运行,在弹出的对话框里输入: cmd /k cd /d "$(CURRENT_DIRECTORY)" &  python " ...

  10. Welcome-to-Swift-24高级运算符(Advanced Operators)

    除了基本操作符中所讲的运算符,Swift还有许多复杂的高级运算符,包括了C语和Objective-C中的位运算符和移位运算. 不同于C语言中的数值计算,Swift的数值计算默认是不可溢出的.溢出行为会 ...