---
title: "maven常用插件--maven-antrun-plugin"
author: "Roger111"
date: "2013-11-26T16:43:18Z"
tags: []
categories: ["研发管理"]
slug: "maven-maven-antrun-plugin"
draft: false
lastmod: "2013-11-26T16:43:18Z"
id: 1981014
url: "https://rogerming.iteye.com/blog/1981014"
---

maven-antrun-plugin为maven提供了ant功能。它只有一个goal，即：

antrun:run 执行ant任务。

 

使用：

```
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.x</version>
```

 该插件有两种方法执行ant任务：

1、可以直接在插件配置中编写

```
       <plugin>
               <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <configuration>
                    <target>
                        <echo message="haha,i can do ant job within maven!"/>
                    </target>
                </configuration>
            </plugin>
```

 2、也可以调用ant脚本即build.xml文件执行

 

```
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <configuration>
                    <target>
                       
                        <ant antfile="${basedir}/build.xml"/>
                    </target>
                </configuration>
            </plugin>
```

 

ss