Maven3 执行ant任务

Maven是杰出的项目管理工具,如今已然代替ANT,成为SCM的老大。但其只是一款项目管理工具,只能通过众多的插件来完成不同的任务,而本身不具有任务执行任务的能力。所以我们在日常开发中,所碰到的一些自定义的需求,不能通过已有插件完成的话,大部分的时候还是需要用ANT来。现在就介绍一下ANT与MAVEN集成的插件。

maven-ant-plugin

一个简单的例子:

 

<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.7</version>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<configuration>
							<tasks>
								<copy todir="${destDir}">
							    	<fileset dir="${sourcedir}">
							    	</fileset>
						    	</copy>
							</tasks>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

 

和普通插件一样,需要goupid, version等。主要的还是在configuration中。

1. 可以直接执行ANT TASK,例如,delete, copy, jar等。具体的ANT task如下 http://ant.apache.org/manual/tasksoverview.html

2. 可以执行ANT 脚本

<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"/>

                <ant antfile="${basedir}/build.xml">
                  <target name="test"/>
                </ant>
              </target>
            </configuration>

 3. 部分ANT 命令已经存在于MAVEN中

 

Ant ExpressionMaven Expression
Built-in Tasks 
Antmaven-antrun-plugin
AntCallmaven-antrun-plugin
Availableprofiles
BUnzip2maven-assembly-plugin
BZip2maven-assembly-plugin
Chmodmaven-assembly-plugin
Conditionprofiles
Copymaven-resources-plugin
Dependsetmaven-dependency-plugin
Earmaven-ear-plugin
Filter maven-resources-plugin Note: Filter uses the @...@ token while maven-resources-plugin uses the  $... token
FixCRLFmaven-resources-plugin
GenKeymaven-jar-plugin
GUnzipmaven-assembly-plugin
GZipmaven-assembly-plugin
Jarmaven-jar-plugin
Javacmaven-compiler-plugin
Javadoc/Javadoc2maven-javadoc-plugin
LoadPropertiesmaven-resources-plugin
Manifestmaven-jar-plugin
Propertymaven-resources-plugin
Replace maven-resources-plugin Note: Replace can specify its token while maven-resources-plugin uses the  $... token
Tarmaven-assembly-plugin
Unjarmaven-assembly-plugin
Untarmaven-assembly-plugin
Unwarmaven-assembly-plugin
Unzipmaven-assembly-plugin
Warmaven-war-plugin
Zipmaven-assembly-plugin
Optional Tasks 
Antlrmaven-antlr-plugin
Dependmaven-dependency-plugin
EJB Tasksmaven-ejb-plugin
FTP maven-deploy-plugin Note: maven-deploy-plugin can only deploy unto the FTP
JavaCCmaven-compiler-plugin
JJDocmaven-compiler-plugin
JJTreemaven-compiler-plugin
JUnitmaven-surefire-plugin
JUnitReportmaven-surefire-report-plugin
ServerDeploymaven-deploy-plugin
Setproxymaven-deploy-plugin
Translate maven-resources-plugin Note: Translate can specify its own tokens and can have a different encoding scheme for reading and writing files. maven-resources-plugin however uses the  $... annotation only and has only one encoding scheme for reading and writing

 

具体的介绍可见官网 http://maven.apache.org/plugins/maven-antrun-plugin/index.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值