下载解压后进入bin目录,并在此目录打开cmd
在cmd中运行ant,运行结果为:
Buildfile: build.xml does not exist!
Build failed
build.xml需要我们创建,其中包含了构建信息:
<?xml version="1.0" encoding="utf-8"?> <project name="hosa" basedir="C:UsersWolfDesktopDestJar" default="makeSuperJar" > <!--basedir:生成的jar的目标目录,将要合并的jar也放置于此--> <target name="makeSuperJar" description="description" > <jar destfile="SampleDemo.jar" > <!--destfile:要生成的jar的目标文件名--> <zipfileset src="LIBMD5.jar" /> <zipfileset src="Sample.jar" /> <!--zipfileset:要参与合并的jar--> </jar> </target> </project>
再次运行ant,输出结果为
Buildfile: C:UsersWolfDesktopapache-ant-1.10.3inuild.xml
makeSuperJar:
[jar] Building jar: C:UsersWolfDesktopDestJarSampleDemo.jar
BUILD SUCCESSFUL
Total time: 0 seconds
构建成功,在目标目录DestJar已生成SampleDemo.jar