Apache Ant 初步体验(小记)

王朝网络·java/jsp·作者佚名  2006-01-10
宽屏版  字体: |||超大  

很早就听说了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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有