当前位置:首页 > 计算机网络 > 软件工程/开发项目管理 > Ant权威指南章节试读
出版社:中国电力出版社
出版日期:2003-1
ISBN:9787508314174
作者:Eric M. Burke
页数:369页
《Ant权威指南》的笔记-运行ANT - 运行ANT
若调用ant时未指定一个构建文件名,ant会在当前工作目录搜索一个名
为build.xml的文件。也可以指定构建文件:ant -buildfile proj.xml
也可以显示的指定一个或多个要运行的目标
如:
ant clean
ant clean jar
获得帮助
ant -projecthelp
ant -help
《Ant权威指南》的笔记-ant入门 - ant入门
build.xml
<?xml version="1.0"?>
<project name="simple buildfile" default="compile" basedir=".">
<!--the directory containing source code-->
<property name="src.dir" value="src"/>
<!--temporary build directories-->
<property name="build.dir" value="build"/>
<property name="build.classes" value="${build.dir}/clasess"/>
<property name="build.lib" value="{build.dir}/lib"/>
<target name="prepare">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes}"/>
<mkdir dir="${build.lib}"/>
</target>
<target name="clean" description="Remove all generated files.">
<delete dir="${build.dir}"/>
</target>
<target name="compile" depends="prepare" description="Compiles all source code">
<javac srcdir="${src.dir}" destdir="${build.classes}"/>
</target>
<target name="jar" depends="compile"
description="Generates oreilly.jar in the 'dist' directory.">
<!--Exclute unit tests from the final JAR file-->
<jar jarfile="${build.lib}/oreilly.jar"
basedir="${build.classes}"
excludes="**/*Test.class"/>
</target>
<target name="all" depends="clean,jar"
description="Clean,compiles,then builds the JAR file"/>
</project>
《Ant权威指南》的笔记-安装和配置 - 安装和配置
设置ANT_HOME
设置JAVA_HOME指向JDK
PATH增加ANT_HOME/bin
配置ANT环境的批处理
@echo off
set ANT_HOME=C:\ant\ant_1.4.1
set JAVA_HOME=C:\java\jdk1.4
set PATH=%ANT_HOME%\bin;%PATH%