- 浏览: 205917 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (75)
- java (2)
- maven (4)
- 后连数据优化 (0)
- spring (4)
- 算法 (1)
- java-struts2 (1)
- javascript (2)
- 其他 (2)
- mysql (1)
- javascript-dwr (1)
- SSH (1)
- 设计模式 (3)
- 搜索引擎 (2)
- 数据优化 (0)
- linux (2)
- 音频、视频工具 (1)
- 语音识别 (1)
- GSON (1)
- Mybatis (1)
- JNDI (1)
- log4j (1)
- iptables (1)
- 系统安全配置 (1)
- 暴力破解 (1)
- jquery (1)
- 无线互联网 (0)
- liunx管理 (7)
- J2EE (0)
- 感悟 (0)
- 图片处理 (1)
- java自定义标签、自定义函数、taglib (1)
- sturts (1)
- 项目管理 (1)
- 测试软件破解 (1)
- spring aop (1)
- spring2.0+hibernate3.0 (1)
- jstl el tag (1)
- oracle (1)
- tomcat (2)
- bug 跟踪 (1)
- DBCP、 DB 配置 (1)
- liunx (1)
最新评论
-
抛出一枚硬币:
在windows下可以转MP3,然而在linux下转的MP3都 ...
JAVE 音频、视频转换工具 -
xierui:
楼主辛苦了, 问下其它音频格式的参数如何获取呀, 如amr, ...
JAVE 音频、视频转换工具 -
Jj1105190650:
gif分解成jpg后,图片的色相不对了,偏红,求解
JPG/GIF合成和分解 -
zhaoleiJE:
public static String toMPTree(S ...
JAVE 音频、视频转换工具 -
sai901013:
謝謝 交作業.
C栈-链表实现
ant学习笔记:
ant:一款针对JAVA的代码编译、管理、处理其依赖关系的工具。因其灵活、易用,故被大量使用。
*ant安装:
1.下载最新ant软件包:
http://ant.apache.org/ 官方网站上下载最新的对应版本,liunx下载tar.gz,window下载zip。
2.下载JDK
3.安装JDK
4.设置JDK环境变量
JAVA_HOME: JDK安装更目录
CLASSPATH: 定义类加载的路径。定位到JDK安装根目录下的lib目录,将当前目录添加到类路径下。
PATH: 定义JAVA,JAVAC命令的路径,将JDK/JRE的bin目录添加到path中。
5.设置ANT环境变量
ANT_HOME: ant包的根目录。
PATH: 将ant包的bin目录添加到path中。
* ant安装测试:
进入命令行,输入ant -verion 、ant -h 显示ant 的版本信息,帮助信息表示ant安装成功。
* ant是基于XML文件的配置,默认配置文件为build.xml,先看一个例子:
<?xml version="1.0" ?>
<project name="MyProject" default="dist" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="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"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- 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" description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
简单的讲,build.xml文件有多个target组成。
* 下面解析build.xml文件的构成,XML文件配置基本格式如下:
1.project 元素: 用于定义一个工程,通常一个文件仅包含一个工程的配置
name: 工程名
basedir: 相对路径,可以被basedir属性覆盖,如果basedir设置,此路径将失效。如果两者都没有设置,就以build.xml文件的目录为basedir。
default: 默认执行的target
例子:
<project name="MyProject" default="dist" basedir=".">
2.target 元素: 用于定义一个执行任务,ant的核心内容
name: target名字
depends: 依赖的target名字,依赖性确定了target执行顺序
if: 其值为某个属性值,进行依赖性检查,当某个属性值设置,才执行该target
unless: 其值为某个属性值,进行依赖性检查,当某个属性值没有设置,才执行该target
description: target的描述信息,当你使用-projecthelp命令行选项时,该信息将会被打印到控制台,用于表示build.xml的执行顺序
重点:target依赖关系,用于定义target执行的先后顺序,如:
<target name="clean" />
<target name="init" depends="clean" />
<target name="compile" depends="init" />
<target name="package" depends="complie" />
通过depends控制执行的顺序为 clean -> init -> compiler -> package
if、unless用于检查属性是否设置,来控制该target是否执行。
例子:
<target name="clean" description="clean old file">
<delete dir="${build}" />
<delete dir="${dest}" />
</target>
<target name="init" depends="clean" description="init process">
<tstamp/>
<mkdir dir="${build}" />
<mkdir dir="${dest}" />
<copy todir="${build}">
<fileset dir="${src}" exclude="**\*.java" /> <!-- ** 表示所有目录 , *.java表示java源文件-->
</copy>
</target>
<target name="compile" depends="init" description="complie the source file" >
<javac basedir="${src}" destdir="${build}" />
</target>
3.properties 元素: 定义一个属性,用于给target元素使用。
该元素可以通过六中方式加载属性:
3.1 name: 属性名
value: 属性值,可以是一个字符串,也可以是其他属性的的name,通过${name}引用其他属性的value
3.2 name: 属性名
location: 属性值,通常用于定义路径,只要是用于解决不同平台下路径分隔符的异同。
3.3 url: 通过读取网络资源加载在其中定义的property
3.4 resource:通过读取资源文件的方式加载在其中定义的property
3.5 file: 通过读取文件方式的加载在其中定义的property
3.6 env :
例子:
设置foo.dist到dist值
<property name="foo.dist" value="dist"/>
读取foo.properties,加载其中定义的属性值
<property file="foo.properties"/>
读取URL指定的资源,从其中加载属性值
<property url="http://www.mysite.com/bla/props/foo.properties"/>
reads a set of properties from a resource called "foo.properties".
<property resource="foo.properties"/>
<property file="${user.home}/.ant-global.properties"/>
since the "user.home" property is defined by the Java virtual machine to be your home directory. Where the "user.home" property resolves to in the file system depends on the operating system version and the JVM implementation. On Unix based systems, this will map to the user's home directory. On modern Windows variants, this will most likely resolve to the user's directory in the "Documents and Settings" folder. Older windows variants such as Windows 98/ME are less predictable, as are other operating system/JVM combinations.
<property environment="env"/>
<echo message="Number of Processors = ${env.NUMBER_OF_PROCESSORS}"/>
<echo message="ANT_HOME is set to = ${env.ANT_HOME}"/>
* 其他元素:
<echo>helloword</echo> 输出内容到控制台
<description>this is a project description</description> 工程的描述信息
* 文件操作命令:
1. copy、copydir、copyfile
1.1 copy
copy当个文件 <copy file="myfile.txt" tofile="mycopy.txt"/>
copy文件到目录 <copy file="myfile.txt" todir="../some/other/dir"/>
copy整个路径到另一个路径,借助fileset 的 dir属性
<copy todir="../new/dir">
<fileset dir="src_dir"/>
</copy>
copy某个路径的部分文件到另一路径,通过exclude排除部分文件,也可以通过include
<copy todir="../dest/dir">
<fileset dir="src_dir">
<exclude name="**/*.java"/>
</fileset>
</copy>
等同于
<copy todir="../dest/dir">
<fileset dir="src_dir" excludes="**/*.java"/>
</copy>
给copy过去的文件添加一个后缀名.bak
<copy todir="../backup/dir">
<fileset dir="src_dir"/>
<globmapper from="*" to="*.bak"/>
</copy>
delete
删除某个文件 <delete file="/lib/ant.jar"/>
删除一个目录 <delete dir="lib"/>
删除所有名字以.bak结尾的文件。模糊匹配
<delete>
<fileset dir="." includes="**/*.bak"/>
</delete>
删除所有的子文件夹和子文件。包括build自身。
<delete includeemptydirs="true">
<fileset dir="build" includes="**/*"/>
</delete>
执行系统命令
<target name="help">
<exec executable="cmd">
<arg value="/c"/>
<arg value="ant.bat"/>
<arg value="-p"/>
</exec>
</target>
jar:
<jar destfile="${dist}/lib/app.jar" basedir="${build}/classes"/>
jars all files in the ${build}/classes directory into a file called app.jar in the ${dist}/lib directory.
<jar destfile="${dist}/lib/app.jar"
basedir="${build}/classes"
excludes="**/Test.class"
/>
jars all files in the ${build}/classes directory into a file called app.jar in the ${dist}/lib directory. Files with the name Test.class are excluded.
<jar destfile="${dist}/lib/app.jar"
basedir="${build}/classes"
includes="mypackage/test/**"
excludes="**/Test.class"
/>
jars all files in the ${build}/classes directory into a file called app.jar in the ${dist}/lib directory. Only files under the directory mypackage/test are used, and files with the name Test.class are excluded.
<jar destfile="${dist}/lib/app.jar">
<fileset dir="${build}/classes"
excludes="**/Test.class"/>
<fileset dir="${src}/resources"/>
</jar>
jars all files in the ${build}/classes directory and also in the ${src}/resources directory together into a file called app.jar in the ${dist}/lib directory. Files with the name Test.class are excluded. If there are files such as ${build}/classes/mypackage/MyClass.class and ${src}/resources/mypackage/image.gif, they will appear in the same directory in the JAR (and thus be considered in the same package by Java).
<jar destfile="test.jar" basedir=".">
<include name="build"/>
<manifest>
<!-- Who is building this jar? -->
<attribute name="Built-By" value="kev"/>
<!-- Information about the program itself -->
<attribute name="Implementation-Vendor" value="ACME inc."/>
<attribute name="Implementation-Title" value="GreatProduct"/>
<attribute name="Implementation-Version" value="1.0.0beta2"/>
<!-- details -->
<section name="common/class1.class">
<attribute name="Sealed" value="false"/>
</section>
</manifest>
</jar>
This is an example of an inline manifest specification including the version of the build program (Implementation-Version). Note that the Built-By attribute will take the value of the Ant property kev. The manifest produced by the above would look like this:
Manifest-Version: 1.0
Built-By: conor
Implementation-Vendor: ACME inc.
Implementation-Title: GreatProduct
Implementation-Version: 1.0.0beta2
Created-By: Apache Ant 1.7.0
Name: common/MyClass.class
Sealed: false
The following shows how to create a jar file specifing a service with an implementation of the JDK6 scripting interface:
<jar jarfile="pinky.jar">
<fileset dir="build/classes"/>
<service type="javax.script.ScriptEngineFactory"
provider="org.acme.PinkyLanguage"/>
</jar>
The following shows how to create a jar file specifing a service with two implementations of the JDK6 scripting interface:
<jar jarfile="pinkyandbrain.jar">
<fileset dir="classes"/>
<service type="javax.script.ScriptEngineFactory">
<provider classname="org.acme.PinkyLanguage"/>
<provider classname="org.acme.BrainLanguage"/>
</service>
</jar>
javac:
<javac srcdir="${src}"
destdir="${build}"
classpath="xyz.jar"
debug="on"
source="1.4"
/>
compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory. The classpath used includes xyz.jar, and compiling with debug information is on. The source level is 1.4, so you can use assert statements.
<javac srcdir="${src}"
destdir="${build}"
fork="true"
source="1.2"
target="1.2"
/>
compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory. This will fork off the javac compiler using the default javac executable. The source level is 1.2 (similar to 1.1 or 1.3) and the class files should be runnable under JDK 1.2+ as well.
<javac srcdir="${src}"
destdir="${build}"
fork="java$javac.exe"
source="1.5"
/>
compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory. This will fork off the javac compiler, using the executable named java$javac.exe. Note that the $ sign needs to be escaped by a second one. The source level is 1.5, so you can use generics.
<javac srcdir="${src}"
destdir="${build}"
includes="mypackage/p1/**,mypackage/p2/**"
excludes="mypackage/p1/testpackage/**"
classpath="xyz.jar"
debug="on"
/>
compiles .java files under the ${src} directory, and stores the .class files in the ${build} directory. The classpath used includes xyz.jar, and debug information is on. Only files under mypackage/p1 and mypackage/p2 are used. All files in and below the mypackage/p1/testpackage directory are excluded from compilation. You didn't specify a source or target level, so the actual values used will depend on which JDK you ran Ant with.
<javac srcdir="${src}:${src2}"
destdir="${build}"
includes="mypackage/p1/**,mypackage/p2/**"
excludes="mypackage/p1/testpackage/**"
classpath="xyz.jar"
debug="on"
/>
is the same as the previous example, with the addition of a second source path, defined by the property src2. This can also be represented using nested <src> elements as follows:
<javac destdir="${build}"
classpath="xyz.jar"
debug="on">
<src path="${src}"/>
<src path="${src2}"/>
<include name="mypackage/p1/**"/>
<include name="mypackage/p2/**"/>
<exclude name="mypackage/p1/testpackage/**"/>
</javac>
If you want to run the javac compiler of a different JDK, you should tell Ant, where to find the compiler and which version of JDK you will be using so it can choose the correct command line switches. The following example executes a JDK 1.1 javac in a new process and uses the correct command line switches even when Ant is running in a Java VM of a different version:
<javac srcdir="${src}"
destdir="${build}"
fork="yes"
executable="/opt/java/jdk1.1/bin/javac"
compiler="javac1.1"
/>
Note: If you wish to compile only source files located in certain packages below a common root, use the include/exclude attributes or <include>/<exclude> nested elements to filter for these packages. Do not include part of your package structure in the srcdir attribute (or nested <src> elements), or Ant will recompile your source files every time you run your compile target. See the Ant FAQ for additional information.
If you wish to compile only files explicitly specified and disable javac's default searching mechanism then you can unset the sourcepath attribute:
<javac sourcepath="" srcdir="${src}"
destdir="${build}" >
<include name="**/*.java"/>
<exclude name="**/Example.java"/>
</javac>
That way the javac will compile all java source files under "${src}" directory but skip the examples. The compiler will even produce errors if some of the non-example files refers to them.
If you wish to compile with a special JDK (another than the one Ant is currently using), set the executable and fork attribute. Using taskname could show in the log, that these settings are fix.
<javac srcdir=""
destdir=""
executable="path-to-java14-home/bin/javac"
fork="true"
taskname="javac1.4" />
Note: If you are using Ant on Windows and a new DOS window pops up for every use of an external compiler, this may be a problem of the JDK you are using. This problem may occur with all JDKs < 1.2.
If you want to activate other compiler options like lint you could use the <compilerarg> element:
<javac srcdir="src"
destdir="${classes.dir}"
classpathref="libraries">
<compilerarg value="-Xlint"/>
</javac>
ZIP命令:
<zip destfile="${dist}/manual.zip"
basedir="htdocs/manual"
/>
zips all files in the htdocs/manual directory into a file called manual.zip in the ${dist} directory.
<zip destfile="${dist}/manual.zip"
basedir="htdocs/manual"
update="true"
/>
zips all files in the htdocs/manual directory into a file called manual.zip in the ${dist} directory. If manual.zip doesn't exist, it is created; otherwise it is updated with the new/changed files.
<zip destfile="${dist}/manual.zip"
basedir="htdocs/manual"
excludes="mydocs/**, **/todo.html"
/>
zips all files in the htdocs/manual directory. Files in the directory mydocs, or files with the name todo.html are excluded.
<zip destfile="${dist}/manual.zip"
basedir="htdocs/manual"
includes="api/**/*.html"
excludes="**/todo.html"
/>
zips all files in the htdocs/manual directory. Only html files under the directory api are zipped, and files with the name todo.html are excluded.
<zip destfile="${dist}/manual.zip">
<fileset dir="htdocs/manual"/>
<fileset dir="." includes="ChangeLog.txt"/>
</zip>
zips all files in the htdocs/manual directory, and also adds the file ChangeLog.txt in the current directory. ChangeLog.txt will be added to the top of the ZIP file, just as if it had been located at htdocs/manual/ChangeLog.txt.
<zip destfile="${dist}/manual.zip">
<zipfileset dir="htdocs/manual" prefix="docs/user-guide"/>
<zipfileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/>
<zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/>
</zip>
zips all files in the htdocs/manual directory into the docs/user-guide directory in the archive, adds the file ChangeLog27.txt in the current directory as docs/ChangeLog.txt, and includes all the html files in examples.zip under docs/examples. The archive might end up containing the files:
docs/user-guide/html/index.html
docs/ChangeLog.txt
docs/examples/index.html
The code
<zip destfile="${dist}/manual.zip">
<zipfileset dir="htdocs/manual" prefix="docs/user-guide"/>
<zipgroupfileset dir="." includes="examples*.zip"/>
</zip>
zips all files in the htdocs/manual directory into the docs/user-guide directory in the archive and includes all the files in any file that maches examples*.zip, such as all files within examples1.zip or examples_for_brian.zip.
<zip dest="release.zip">
<tarfileset src="release.tar"/>
</zip>
UNZIP:
<unzip src="${tomcat_src}/tools-src.zip" dest="${tools.home}"/>
<gunzip src="tools.tar.gz"/>
<untar src="tools.tar" dest="${tools.home}"/>
<unzip src="${tomcat_src}/tools-src.zip"
dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
</unzip>
<unzip dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
<fileset dir=".">
<include name="**/*.zip"/>
<exclude name="**/tmp*.zip"/>
</fileset>
</unzip>
<unzip src="apache-ant-bin.zip" dest="${tools.home}">
<patternset>
<include name="apache-ant/lib/ant.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
Related tasks
<unzip src="some-archive" dest="some-dir">
<patternset>
<include name="some-pattern"/>
</patternset>
<mapper type="some-mapper"/>
</unzip>
is identical to
<copy todir="some-dir" preservelastmodified="true">
<zipfileset src="some-archive">
<patternset>
<include name="some-pattern"/>
</patternset>
</zipfileset>
<mapper type="some-mapper"/>
</copy>
The same is also true for <untar> and <tarfileset>. <copy> offers additional features like filtering files on the fly, allowing a file to be mapped to multiple destinations or a configurable file system timestamp granularity.
<zip destfile="new.jar">
<zipfileset src="old.jar">
<exclude name="do/not/include/this/class"/>
</zipfileset>
</zip>
UNZIP:
unzip src="${tomcat_src}/tools-src.zip" dest="${tools.home}"/>
<gunzip src="tools.tar.gz"/>
<untar src="tools.tar" dest="${tools.home}"/>
<unzip src="${tomcat_src}/tools-src.zip"
dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
</unzip>
<unzip dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
<fileset dir=".">
<include name="**/*.zip"/>
<exclude name="**/tmp*.zip"/>
</fileset>
</unzip>
<unzip src="apache-ant-bin.zip" dest="${tools.home}">
<patternset>
<include name="apache-ant/lib/ant.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
Related tasks
<unzip src="some-archive" dest="some-dir">
<patternset>
<include name="some-pattern"/>
</patternset>
<mapper type="some-mapper"/>
</unzip>
is identical to
<copy todir="some-dir" preservelastmodified="true">
<zipfileset src="some-archive">
<patternset>
<include name="some-pattern"/>
</patternset>
</zipfileset>
<mapper type="some-mapper"/>
</copy>
The same is also true for <untar> and <tarfileset>. <copy> offers additional features like filtering files on the fly, allowing a file to be mapped to multiple destinations or a configurable file system timestamp granularity.
<zip destfile="new.jar">
<zipfileset src="old.jar">
<exclude name="do/not/include/this/class"/>
</zipfileset>
</zip>
UNwar:
<unzip src="${tomcat_src}/tools-src.zip" dest="${tools.home}"/>
<gunzip src="tools.tar.gz"/>
<untar src="tools.tar" dest="${tools.home}"/>
<unzip src="${tomcat_src}/tools-src.zip"
dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
</unzip>
<unzip dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
<fileset dir=".">
<include name="**/*.zip"/>
<exclude name="**/tmp*.zip"/>
</fileset>
</unzip>
<unzip src="apache-ant-bin.zip" dest="${tools.home}">
<patternset>
<include name="apache-ant/lib/ant.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
Related tasks
<unzip src="some-archive" dest="some-dir">
<patternset>
<include name="some-pattern"/>
</patternset>
<mapper type="some-mapper"/>
</unzip>
is identical to
<copy todir="some-dir" preservelastmodified="true">
<zipfileset src="some-archive">
<patternset>
<include name="some-pattern"/>
</patternset>
</zipfileset>
<mapper type="some-mapper"/>
</copy>
The same is also true for <untar> and <tarfileset>. <copy> offers additional features like filtering files on the fly, allowing a file to be mapped to multiple destinations or a configurable file system timestamp granularity.
<zip destfile="new.jar">
<zipfileset src="old.jar">
<exclude name="do/not/include/this/class"/>
</zipfileset>
</zip>
Unjar:
<unzip src="${tomcat_src}/tools-src.zip" dest="${tools.home}"/>
<gunzip src="tools.tar.gz"/>
<untar src="tools.tar" dest="${tools.home}"/>
<unzip src="${tomcat_src}/tools-src.zip"
dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
</unzip>
<unzip dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
<fileset dir=".">
<include name="**/*.zip"/>
<exclude name="**/tmp*.zip"/>
</fileset>
</unzip>
<unzip src="apache-ant-bin.zip" dest="${tools.home}">
<patternset>
<include name="apache-ant/lib/ant.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
Related tasks
<unzip src="some-archive" dest="some-dir">
<patternset>
<include name="some-pattern"/>
</patternset>
<mapper type="some-mapper"/>
</unzip>
is identical to
<copy todir="some-dir" preservelastmodified="true">
<zipfileset src="some-archive">
<patternset>
<include name="some-pattern"/>
</patternset>
</zipfileset>
<mapper type="some-mapper"/>
</copy>
The same is also true for <untar> and <tarfileset>. <copy> offers additional features like filtering files on the fly, allowing a file to be mapped to multiple destinations or a configurable file system timestamp granularity.
<zip destfile="new.jar">
<zipfileset src="old.jar">
<exclude name="do/not/include/this/class"/>
</zipfileset>
</zip>
War:
thirdparty/libs/jdbc1.jar
thirdparty/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif
then the war file myapp.war created with
<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
<fileset dir="src/html/myapp"/>
<fileset dir="src/jsp/myapp"/>
<lib dir="thirdparty/libs">
<exclude name="jdbc1.jar"/>
</lib>
<classes dir="build/main"/>
<zipfileset dir="src/graphics/images/gifs"
prefix="images"/>
</war>
will consist of
WEB-INF/web.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
images/small/logo.gif
images/large/logo.gif
using Ant's default manifest file. The content of WEB-INF/web.xml is identical to src/metadata/myapp.xml.
We regulary receive
ant:一款针对JAVA的代码编译、管理、处理其依赖关系的工具。因其灵活、易用,故被大量使用。
*ant安装:
1.下载最新ant软件包:
http://ant.apache.org/ 官方网站上下载最新的对应版本,liunx下载tar.gz,window下载zip。
2.下载JDK
3.安装JDK
4.设置JDK环境变量
JAVA_HOME: JDK安装更目录
CLASSPATH: 定义类加载的路径。定位到JDK安装根目录下的lib目录,将当前目录添加到类路径下。
PATH: 定义JAVA,JAVAC命令的路径,将JDK/JRE的bin目录添加到path中。
5.设置ANT环境变量
ANT_HOME: ant包的根目录。
PATH: 将ant包的bin目录添加到path中。
* ant安装测试:
进入命令行,输入ant -verion 、ant -h 显示ant 的版本信息,帮助信息表示ant安装成功。
* ant是基于XML文件的配置,默认配置文件为build.xml,先看一个例子:
<?xml version="1.0" ?>
<project name="MyProject" default="dist" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="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"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>
<target name="dist" depends="compile"
description="generate the distribution" >
<!-- 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" description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
简单的讲,build.xml文件有多个target组成。
* 下面解析build.xml文件的构成,XML文件配置基本格式如下:
1.project 元素: 用于定义一个工程,通常一个文件仅包含一个工程的配置
name: 工程名
basedir: 相对路径,可以被basedir属性覆盖,如果basedir设置,此路径将失效。如果两者都没有设置,就以build.xml文件的目录为basedir。
default: 默认执行的target
例子:
<project name="MyProject" default="dist" basedir=".">
2.target 元素: 用于定义一个执行任务,ant的核心内容
name: target名字
depends: 依赖的target名字,依赖性确定了target执行顺序
if: 其值为某个属性值,进行依赖性检查,当某个属性值设置,才执行该target
unless: 其值为某个属性值,进行依赖性检查,当某个属性值没有设置,才执行该target
description: target的描述信息,当你使用-projecthelp命令行选项时,该信息将会被打印到控制台,用于表示build.xml的执行顺序
重点:target依赖关系,用于定义target执行的先后顺序,如:
<target name="clean" />
<target name="init" depends="clean" />
<target name="compile" depends="init" />
<target name="package" depends="complie" />
通过depends控制执行的顺序为 clean -> init -> compiler -> package
if、unless用于检查属性是否设置,来控制该target是否执行。
例子:
<target name="clean" description="clean old file">
<delete dir="${build}" />
<delete dir="${dest}" />
</target>
<target name="init" depends="clean" description="init process">
<tstamp/>
<mkdir dir="${build}" />
<mkdir dir="${dest}" />
<copy todir="${build}">
<fileset dir="${src}" exclude="**\*.java" /> <!-- ** 表示所有目录 , *.java表示java源文件-->
</copy>
</target>
<target name="compile" depends="init" description="complie the source file" >
<javac basedir="${src}" destdir="${build}" />
</target>
3.properties 元素: 定义一个属性,用于给target元素使用。
该元素可以通过六中方式加载属性:
3.1 name: 属性名
value: 属性值,可以是一个字符串,也可以是其他属性的的name,通过${name}引用其他属性的value
3.2 name: 属性名
location: 属性值,通常用于定义路径,只要是用于解决不同平台下路径分隔符的异同。
3.3 url: 通过读取网络资源加载在其中定义的property
3.4 resource:通过读取资源文件的方式加载在其中定义的property
3.5 file: 通过读取文件方式的加载在其中定义的property
3.6 env :
例子:
设置foo.dist到dist值
<property name="foo.dist" value="dist"/>
读取foo.properties,加载其中定义的属性值
<property file="foo.properties"/>
读取URL指定的资源,从其中加载属性值
<property url="http://www.mysite.com/bla/props/foo.properties"/>
reads a set of properties from a resource called "foo.properties".
<property resource="foo.properties"/>
<property file="${user.home}/.ant-global.properties"/>
since the "user.home" property is defined by the Java virtual machine to be your home directory. Where the "user.home" property resolves to in the file system depends on the operating system version and the JVM implementation. On Unix based systems, this will map to the user's home directory. On modern Windows variants, this will most likely resolve to the user's directory in the "Documents and Settings" folder. Older windows variants such as Windows 98/ME are less predictable, as are other operating system/JVM combinations.
<property environment="env"/>
<echo message="Number of Processors = ${env.NUMBER_OF_PROCESSORS}"/>
<echo message="ANT_HOME is set to = ${env.ANT_HOME}"/>
* 其他元素:
<echo>helloword</echo> 输出内容到控制台
<description>this is a project description</description> 工程的描述信息
* 文件操作命令:
1. copy、copydir、copyfile
1.1 copy
copy当个文件 <copy file="myfile.txt" tofile="mycopy.txt"/>
copy文件到目录 <copy file="myfile.txt" todir="../some/other/dir"/>
copy整个路径到另一个路径,借助fileset 的 dir属性
<copy todir="../new/dir">
<fileset dir="src_dir"/>
</copy>
copy某个路径的部分文件到另一路径,通过exclude排除部分文件,也可以通过include
<copy todir="../dest/dir">
<fileset dir="src_dir">
<exclude name="**/*.java"/>
</fileset>
</copy>
等同于
<copy todir="../dest/dir">
<fileset dir="src_dir" excludes="**/*.java"/>
</copy>
给copy过去的文件添加一个后缀名.bak
<copy todir="../backup/dir">
<fileset dir="src_dir"/>
<globmapper from="*" to="*.bak"/>
</copy>
delete
删除某个文件 <delete file="/lib/ant.jar"/>
删除一个目录 <delete dir="lib"/>
删除所有名字以.bak结尾的文件。模糊匹配
<delete>
<fileset dir="." includes="**/*.bak"/>
</delete>
删除所有的子文件夹和子文件。包括build自身。
<delete includeemptydirs="true">
<fileset dir="build" includes="**/*"/>
</delete>
执行系统命令
<target name="help">
<exec executable="cmd">
<arg value="/c"/>
<arg value="ant.bat"/>
<arg value="-p"/>
</exec>
</target>
jar:
<jar destfile="${dist}/lib/app.jar" basedir="${build}/classes"/>
jars all files in the ${build}/classes directory into a file called app.jar in the ${dist}/lib directory.
<jar destfile="${dist}/lib/app.jar"
basedir="${build}/classes"
excludes="**/Test.class"
/>
jars all files in the ${build}/classes directory into a file called app.jar in the ${dist}/lib directory. Files with the name Test.class are excluded.
<jar destfile="${dist}/lib/app.jar"
basedir="${build}/classes"
includes="mypackage/test/**"
excludes="**/Test.class"
/>
jars all files in the ${build}/classes directory into a file called app.jar in the ${dist}/lib directory. Only files under the directory mypackage/test are used, and files with the name Test.class are excluded.
<jar destfile="${dist}/lib/app.jar">
<fileset dir="${build}/classes"
excludes="**/Test.class"/>
<fileset dir="${src}/resources"/>
</jar>
jars all files in the ${build}/classes directory and also in the ${src}/resources directory together into a file called app.jar in the ${dist}/lib directory. Files with the name Test.class are excluded. If there are files such as ${build}/classes/mypackage/MyClass.class and ${src}/resources/mypackage/image.gif, they will appear in the same directory in the JAR (and thus be considered in the same package by Java).
<jar destfile="test.jar" basedir=".">
<include name="build"/>
<manifest>
<!-- Who is building this jar? -->
<attribute name="Built-By" value="kev"/>
<!-- Information about the program itself -->
<attribute name="Implementation-Vendor" value="ACME inc."/>
<attribute name="Implementation-Title" value="GreatProduct"/>
<attribute name="Implementation-Version" value="1.0.0beta2"/>
<!-- details -->
<section name="common/class1.class">
<attribute name="Sealed" value="false"/>
</section>
</manifest>
</jar>
This is an example of an inline manifest specification including the version of the build program (Implementation-Version). Note that the Built-By attribute will take the value of the Ant property kev. The manifest produced by the above would look like this:
Manifest-Version: 1.0
Built-By: conor
Implementation-Vendor: ACME inc.
Implementation-Title: GreatProduct
Implementation-Version: 1.0.0beta2
Created-By: Apache Ant 1.7.0
Name: common/MyClass.class
Sealed: false
The following shows how to create a jar file specifing a service with an implementation of the JDK6 scripting interface:
<jar jarfile="pinky.jar">
<fileset dir="build/classes"/>
<service type="javax.script.ScriptEngineFactory"
provider="org.acme.PinkyLanguage"/>
</jar>
The following shows how to create a jar file specifing a service with two implementations of the JDK6 scripting interface:
<jar jarfile="pinkyandbrain.jar">
<fileset dir="classes"/>
<service type="javax.script.ScriptEngineFactory">
<provider classname="org.acme.PinkyLanguage"/>
<provider classname="org.acme.BrainLanguage"/>
</service>
</jar>
javac:
<javac srcdir="${src}"
destdir="${build}"
classpath="xyz.jar"
debug="on"
source="1.4"
/>
compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory. The classpath used includes xyz.jar, and compiling with debug information is on. The source level is 1.4, so you can use assert statements.
<javac srcdir="${src}"
destdir="${build}"
fork="true"
source="1.2"
target="1.2"
/>
compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory. This will fork off the javac compiler using the default javac executable. The source level is 1.2 (similar to 1.1 or 1.3) and the class files should be runnable under JDK 1.2+ as well.
<javac srcdir="${src}"
destdir="${build}"
fork="java$javac.exe"
source="1.5"
/>
compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory. This will fork off the javac compiler, using the executable named java$javac.exe. Note that the $ sign needs to be escaped by a second one. The source level is 1.5, so you can use generics.
<javac srcdir="${src}"
destdir="${build}"
includes="mypackage/p1/**,mypackage/p2/**"
excludes="mypackage/p1/testpackage/**"
classpath="xyz.jar"
debug="on"
/>
compiles .java files under the ${src} directory, and stores the .class files in the ${build} directory. The classpath used includes xyz.jar, and debug information is on. Only files under mypackage/p1 and mypackage/p2 are used. All files in and below the mypackage/p1/testpackage directory are excluded from compilation. You didn't specify a source or target level, so the actual values used will depend on which JDK you ran Ant with.
<javac srcdir="${src}:${src2}"
destdir="${build}"
includes="mypackage/p1/**,mypackage/p2/**"
excludes="mypackage/p1/testpackage/**"
classpath="xyz.jar"
debug="on"
/>
is the same as the previous example, with the addition of a second source path, defined by the property src2. This can also be represented using nested <src> elements as follows:
<javac destdir="${build}"
classpath="xyz.jar"
debug="on">
<src path="${src}"/>
<src path="${src2}"/>
<include name="mypackage/p1/**"/>
<include name="mypackage/p2/**"/>
<exclude name="mypackage/p1/testpackage/**"/>
</javac>
If you want to run the javac compiler of a different JDK, you should tell Ant, where to find the compiler and which version of JDK you will be using so it can choose the correct command line switches. The following example executes a JDK 1.1 javac in a new process and uses the correct command line switches even when Ant is running in a Java VM of a different version:
<javac srcdir="${src}"
destdir="${build}"
fork="yes"
executable="/opt/java/jdk1.1/bin/javac"
compiler="javac1.1"
/>
Note: If you wish to compile only source files located in certain packages below a common root, use the include/exclude attributes or <include>/<exclude> nested elements to filter for these packages. Do not include part of your package structure in the srcdir attribute (or nested <src> elements), or Ant will recompile your source files every time you run your compile target. See the Ant FAQ for additional information.
If you wish to compile only files explicitly specified and disable javac's default searching mechanism then you can unset the sourcepath attribute:
<javac sourcepath="" srcdir="${src}"
destdir="${build}" >
<include name="**/*.java"/>
<exclude name="**/Example.java"/>
</javac>
That way the javac will compile all java source files under "${src}" directory but skip the examples. The compiler will even produce errors if some of the non-example files refers to them.
If you wish to compile with a special JDK (another than the one Ant is currently using), set the executable and fork attribute. Using taskname could show in the log, that these settings are fix.
<javac srcdir=""
destdir=""
executable="path-to-java14-home/bin/javac"
fork="true"
taskname="javac1.4" />
Note: If you are using Ant on Windows and a new DOS window pops up for every use of an external compiler, this may be a problem of the JDK you are using. This problem may occur with all JDKs < 1.2.
If you want to activate other compiler options like lint you could use the <compilerarg> element:
<javac srcdir="src"
destdir="${classes.dir}"
classpathref="libraries">
<compilerarg value="-Xlint"/>
</javac>
ZIP命令:
<zip destfile="${dist}/manual.zip"
basedir="htdocs/manual"
/>
zips all files in the htdocs/manual directory into a file called manual.zip in the ${dist} directory.
<zip destfile="${dist}/manual.zip"
basedir="htdocs/manual"
update="true"
/>
zips all files in the htdocs/manual directory into a file called manual.zip in the ${dist} directory. If manual.zip doesn't exist, it is created; otherwise it is updated with the new/changed files.
<zip destfile="${dist}/manual.zip"
basedir="htdocs/manual"
excludes="mydocs/**, **/todo.html"
/>
zips all files in the htdocs/manual directory. Files in the directory mydocs, or files with the name todo.html are excluded.
<zip destfile="${dist}/manual.zip"
basedir="htdocs/manual"
includes="api/**/*.html"
excludes="**/todo.html"
/>
zips all files in the htdocs/manual directory. Only html files under the directory api are zipped, and files with the name todo.html are excluded.
<zip destfile="${dist}/manual.zip">
<fileset dir="htdocs/manual"/>
<fileset dir="." includes="ChangeLog.txt"/>
</zip>
zips all files in the htdocs/manual directory, and also adds the file ChangeLog.txt in the current directory. ChangeLog.txt will be added to the top of the ZIP file, just as if it had been located at htdocs/manual/ChangeLog.txt.
<zip destfile="${dist}/manual.zip">
<zipfileset dir="htdocs/manual" prefix="docs/user-guide"/>
<zipfileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/>
<zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/>
</zip>
zips all files in the htdocs/manual directory into the docs/user-guide directory in the archive, adds the file ChangeLog27.txt in the current directory as docs/ChangeLog.txt, and includes all the html files in examples.zip under docs/examples. The archive might end up containing the files:
docs/user-guide/html/index.html
docs/ChangeLog.txt
docs/examples/index.html
The code
<zip destfile="${dist}/manual.zip">
<zipfileset dir="htdocs/manual" prefix="docs/user-guide"/>
<zipgroupfileset dir="." includes="examples*.zip"/>
</zip>
zips all files in the htdocs/manual directory into the docs/user-guide directory in the archive and includes all the files in any file that maches examples*.zip, such as all files within examples1.zip or examples_for_brian.zip.
<zip dest="release.zip">
<tarfileset src="release.tar"/>
</zip>
UNZIP:
<unzip src="${tomcat_src}/tools-src.zip" dest="${tools.home}"/>
<gunzip src="tools.tar.gz"/>
<untar src="tools.tar" dest="${tools.home}"/>
<unzip src="${tomcat_src}/tools-src.zip"
dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
</unzip>
<unzip dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
<fileset dir=".">
<include name="**/*.zip"/>
<exclude name="**/tmp*.zip"/>
</fileset>
</unzip>
<unzip src="apache-ant-bin.zip" dest="${tools.home}">
<patternset>
<include name="apache-ant/lib/ant.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
Related tasks
<unzip src="some-archive" dest="some-dir">
<patternset>
<include name="some-pattern"/>
</patternset>
<mapper type="some-mapper"/>
</unzip>
is identical to
<copy todir="some-dir" preservelastmodified="true">
<zipfileset src="some-archive">
<patternset>
<include name="some-pattern"/>
</patternset>
</zipfileset>
<mapper type="some-mapper"/>
</copy>
The same is also true for <untar> and <tarfileset>. <copy> offers additional features like filtering files on the fly, allowing a file to be mapped to multiple destinations or a configurable file system timestamp granularity.
<zip destfile="new.jar">
<zipfileset src="old.jar">
<exclude name="do/not/include/this/class"/>
</zipfileset>
</zip>
UNZIP:
unzip src="${tomcat_src}/tools-src.zip" dest="${tools.home}"/>
<gunzip src="tools.tar.gz"/>
<untar src="tools.tar" dest="${tools.home}"/>
<unzip src="${tomcat_src}/tools-src.zip"
dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
</unzip>
<unzip dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
<fileset dir=".">
<include name="**/*.zip"/>
<exclude name="**/tmp*.zip"/>
</fileset>
</unzip>
<unzip src="apache-ant-bin.zip" dest="${tools.home}">
<patternset>
<include name="apache-ant/lib/ant.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
Related tasks
<unzip src="some-archive" dest="some-dir">
<patternset>
<include name="some-pattern"/>
</patternset>
<mapper type="some-mapper"/>
</unzip>
is identical to
<copy todir="some-dir" preservelastmodified="true">
<zipfileset src="some-archive">
<patternset>
<include name="some-pattern"/>
</patternset>
</zipfileset>
<mapper type="some-mapper"/>
</copy>
The same is also true for <untar> and <tarfileset>. <copy> offers additional features like filtering files on the fly, allowing a file to be mapped to multiple destinations or a configurable file system timestamp granularity.
<zip destfile="new.jar">
<zipfileset src="old.jar">
<exclude name="do/not/include/this/class"/>
</zipfileset>
</zip>
UNwar:
<unzip src="${tomcat_src}/tools-src.zip" dest="${tools.home}"/>
<gunzip src="tools.tar.gz"/>
<untar src="tools.tar" dest="${tools.home}"/>
<unzip src="${tomcat_src}/tools-src.zip"
dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
</unzip>
<unzip dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
<fileset dir=".">
<include name="**/*.zip"/>
<exclude name="**/tmp*.zip"/>
</fileset>
</unzip>
<unzip src="apache-ant-bin.zip" dest="${tools.home}">
<patternset>
<include name="apache-ant/lib/ant.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
Related tasks
<unzip src="some-archive" dest="some-dir">
<patternset>
<include name="some-pattern"/>
</patternset>
<mapper type="some-mapper"/>
</unzip>
is identical to
<copy todir="some-dir" preservelastmodified="true">
<zipfileset src="some-archive">
<patternset>
<include name="some-pattern"/>
</patternset>
</zipfileset>
<mapper type="some-mapper"/>
</copy>
The same is also true for <untar> and <tarfileset>. <copy> offers additional features like filtering files on the fly, allowing a file to be mapped to multiple destinations or a configurable file system timestamp granularity.
<zip destfile="new.jar">
<zipfileset src="old.jar">
<exclude name="do/not/include/this/class"/>
</zipfileset>
</zip>
Unjar:
<unzip src="${tomcat_src}/tools-src.zip" dest="${tools.home}"/>
<gunzip src="tools.tar.gz"/>
<untar src="tools.tar" dest="${tools.home}"/>
<unzip src="${tomcat_src}/tools-src.zip"
dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
</unzip>
<unzip dest="${tools.home}">
<patternset>
<include name="**/*.java"/>
<exclude name="**/Test*.java"/>
</patternset>
<fileset dir=".">
<include name="**/*.zip"/>
<exclude name="**/tmp*.zip"/>
</fileset>
</unzip>
<unzip src="apache-ant-bin.zip" dest="${tools.home}">
<patternset>
<include name="apache-ant/lib/ant.jar"/>
</patternset>
<mapper type="flatten"/>
</unzip>
Related tasks
<unzip src="some-archive" dest="some-dir">
<patternset>
<include name="some-pattern"/>
</patternset>
<mapper type="some-mapper"/>
</unzip>
is identical to
<copy todir="some-dir" preservelastmodified="true">
<zipfileset src="some-archive">
<patternset>
<include name="some-pattern"/>
</patternset>
</zipfileset>
<mapper type="some-mapper"/>
</copy>
The same is also true for <untar> and <tarfileset>. <copy> offers additional features like filtering files on the fly, allowing a file to be mapped to multiple destinations or a configurable file system timestamp granularity.
<zip destfile="new.jar">
<zipfileset src="old.jar">
<exclude name="do/not/include/this/class"/>
</zipfileset>
</zip>
War:
thirdparty/libs/jdbc1.jar
thirdparty/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif
then the war file myapp.war created with
<war destfile="myapp.war" webxml="src/metadata/myapp.xml">
<fileset dir="src/html/myapp"/>
<fileset dir="src/jsp/myapp"/>
<lib dir="thirdparty/libs">
<exclude name="jdbc1.jar"/>
</lib>
<classes dir="build/main"/>
<zipfileset dir="src/graphics/images/gifs"
prefix="images"/>
</war>
will consist of
WEB-INF/web.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
images/small/logo.gif
images/large/logo.gif
using Ant's default manifest file. The content of WEB-INF/web.xml is identical to src/metadata/myapp.xml.
We regulary receive
相关推荐
《Ant学习笔记:详解Ant执行命令参数与系统属性》 Ant,作为一个基于Java的构建工具,因其跨平台性以及XML格式的构建脚本而被广泛应用于自动化构建过程,如编译、打包、测试等。本篇文章将深入探讨Ant执行命令的...
根据提供的文件信息,这里将深入解析“ant学习笔记:一个简单的java编译部署实例”,涵盖标题、描述、标签以及部分内容中提及的关键知识点。 ### Apache Ant简介 Apache Ant是一款开源的Java环境下的自动化构建...
**Ant学习笔记** Ant是一个基于Java的构建工具,它的全称是Another Neat Tool,主要应用于Java项目的构建。Ant的设计理念是通过XML配置文件来定义构建过程,而非依赖于特定平台的shell命令。每个构建任务是由实现了...
**Ant学习笔记** Apache Ant,一个Java库和命令行工具,其任务是驱动构建过程。它是Java世界中广泛使用的构建工具,类似于Unix世界的Make。Ant以其XML格式的构建文件(通常命名为`build.xml`)而闻名,这个文件包含...
### ant学习笔记:深入了解ant构建工具 #### 引言 `ant`,作为一款源自动网络的学习笔记,主要探讨了Apache Ant这一强大的构建工具。Apache Ant是一款开源的、跨平台的构建工具,专为Java应用程序设计,旨在简化并...
NULL 博文链接:https://worktianqi.iteye.com/blog/2162932
Ant 1.9.1是Ant的一个版本,学习笔记通常记录了使用该工具的基本操作和配置方法。 ### Ant的下载和安装 要使用Ant,首先需要下载并安装。在Windows系统中,通常需要配置环境变量以便于命令行中使用Ant命令。ANT_...
总的来说,这个“ant个人学习笔记和简单示例”应该能帮助你掌握Ant的基本用法,理解构建过程的自动化,以及如何编写和维护自己的构建文件。通过学习和实践其中的示例,你将能够熟练地运用Ant来构建和管理Java项目,...
Java/JavaEE 学习笔记 作者在杰普学习时的学习笔记,是J2ee初学者必备手册,是大家学习J2EE开发的很好的参考笔记。 Java/JavaEE 学习笔记 内容...ant学习笔记...................387 Web Service学习笔记.....388
《Ant构建工具学习指南》 Ant,作为Java领域的一个强大构建工具,它的主要作用在于将复杂的项目构建过程规范化、自动化,使得开发者能够更专注于代码的编写而非构建流程。本文将深入探讨Ant的基本概念、安装配置、...
内容目录 .......................1 Java/JavaEE.....1 2008年11月1日...............1 Unix 学习笔记7 一、Unix前言............7 ...ant学习笔记...................387 Web Service学习笔记.....388
**ANT学习笔记(一)——ANT结合JUNIT4学习DEMO** ANT,全称为Apache Ant,是一个基于Java的构建工具,用于自动化Java项目的构建、编译、测试和部署过程。它通过XML配置文件来定义任务,使得项目构建过程可配置且可...
在本篇ANT学习笔记中,我们将探讨如何将ANT应用于WEB项目的测试DEMO。ANT是一个流行的Java构建工具,它允许开发者自动化构建、测试和部署软件。本文档将介绍ANT的基本概念,以及如何配置和运行一个针对WEB应用的构建...
### ant的学习笔记知识点详解 #### 一、Ant的作用与特性 Ant是一款强大的自动化构建工具,主要应用于Java项目,能够高效地处理项目的编译、打包、测试等任务。它采用XML格式编写构建脚本,这使得Ant具有良好的跨...
在"Ant打包编译部署工具学习笔记2"中,我们可以预期博主分享了关于如何利用Ant进行更复杂的构建操作,例如集成测试、优化和打包。这可能包括如何配置build.xml文件,添加自定义任务,以及如何处理依赖关系。由于没有...
3. **Ant学习笔记.doc与Ant权威指南.pdf** Ant是Java世界里常用的构建工具,能够自动化执行编译、打包、测试等任务。文档和PDF提供了Ant的基本使用、任务定义、宏定义等,对于项目构建流程的管理至关重要。 4. **...