Apache Ant 初步体验(小记)

很早就听说了apache 的这个开源工具,听人说配置繁琐,功能一般,一直没兴趣尝试,因为现在着迷Eclipse IDE,里面内置了ant,爱屋及乌吧,我想以Eclipse的名气和品质,ant也是很好用的吧

1,先下载一个ant1.6,不会Http://ant.apache.org最近上不去了,可以到网上找一下本地下载

2 apache-ant-1.6.2-bin.zip解压 有一个Bib目录 把windows下的path指到这里

3.cmd进入控制台,输入ant -h   回车 看到帮助信息

4.在当前目录下建一个test.java文件

5 建一个build.xml文件

<project name="MyProject" default="dist" basedir=".">

<!-- set global properties for this build -->
<property name="src" value="."/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>

<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>

<target name="compile" depends="init">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>

<target name="dist" depends="compile">
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
</target>

<target name="clean">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>

</project>


6.然后 ant  回车,成功了

从编译到打成jar包,一气合成,真爽!

然后进入Eclipse ,对以前的项目小用了一下,真方便,再也不用修改文件后每次打开winrar,ctrL+C Ctrl+V了

那个build.xml文件是看别人的,里面有些门道,继续研究中。。。

参考文章:

http://www.matrix.org.cn/resource/article/0/518.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值