1. Overview
ANT is a tool that connects software compilation, testing, deployment and other steps to automate, mostly for software development in the Java environment. In actual software development, there are many places to use ANT.
Development environment:
Copy code code as follows:
System: Windows
Jdk: 1.6+
IDE: Eclipse
ant: 1.9.1
Second, advantages
Ant is a sub -project in the Apache Software Foundation's Jakarta directory. It has the following advantages:
1. Cross -platform: ANT is written in pure Java language, so it has good cross -platform.
2. Simple operation: ANT is composed of a built -in task and optional task. The use task is like writing a command line in DOS. ANT requires a XML file (build files). ANT can execute various tasks by calling the target tree. Each task implements specific interface objects.
3. Simple maintenance, good readability, and simply integrated: Because ANT built files, XML format files are easy to maintain and write, and the structure is very clear. ANT can integrate into the development environment. Because ANT's cross -platform and simple operation characteristics, it is easy to integrate into some development environments.
Third, installation and configuration
1. Download ant, http://mirror.esocc.com/apache/ant/binaries/apache-NT -NT-9.1-bin.zip
2. Unzip the ZIP compression package and place the compressed package you want to place the directory you want to place. I place it here in d: /APache-AT-1.9.1, the directory structure is as follows:
BIN is an Ant program running entrance. If it is not configured with ANT_HOME, you can run the BUILD task through the BAT program in the bin directory.
Such as: run Ant.bat in CMD to execute the program. Of course, you choose to have a built.xml in the current directory (build.xml is the default ant execution file. Of course, you can specify other files)
All the XSL output templates are stored in the ETC directory, creating a enhanced export XML output of various tasks, so that your build files get rid of outdated warnings
What is stored in the lib directory is the jar package that the Ant program needs to depend on
Manual directory is the help document of the ant program
3. In my computer> Right-click Properties> Advanced System Configuration-> Configure Ant in Environment variables
New system variable ant_home = d: /APache-AT-1.9.1
In this way, the environment variable is configured, but the premise you need to configure the environment variable of JDK. If you do not configure the environment variable of JDK, then please configure the JDK variable first. The JDK environment configuration method is as follows:
(1) Install JDK to its default directory: C:/Program Files/Java/JDK1.5.0_05 (No JDK goes to the official download one)
C:/Program Files/Java/JDK1.5.0
Role: Tell the system JVM where is JVM
(2) Right -click my computer, select attributes, advanced, environmental variables
(3) Newly built at the system variable bar, a new system variable dialog box appears, and Java_home is filled in the variable name, variable value: C:/Program Files/Java/JDK1.5.0_05
(4) After confirmation, create a new environment variable classpath in the system variable (s) column (s). No less)
(5) After confirmation, find and select the option with the variable as PATH in the system variable (s) column.
%Java_home%/bin
If not found PATH variables, create a new one yourself!
If you don't want to run to the directory where Class is located every time you run, and then execute the java command, you can put all the class files under the unified directory organization, and then add this directory to ClassPath.
The test code is as follows:
Copy code code as follows:
public class test {
Public Static Void Main (String [] args) {{
System.out.println ("Hello World!");
}
}
After the editor of the Notepad is edited as a test.java (the file name and the same name) file, open the command line window,
CD to the directory where the file is located:
Copy code code as follows:
javac test.java // compile commands
java test // execute program
If the output is: Hello World! OK, configured, otherwise, check it again.
Fourth, test ant
Enter the ant in the DOS window running CMD, as shown in the figure:
If this appears, then congratulations on your installation! Otherwise, it will fail, and check the previous steps wrong. The above command will execute the Ant program, and Ant performs the task in the BUILD.XML by default. There is no such file in the Administrator directory.
If the installation fails, see if there are some situations:
1. No configuration java_home or configuration error, and java_home/bin/java.exe exists
2. No configuration Ant_hoem or configuration error, and ant_home/bin/ant.bat exists
3. Check the PATH variables of your environment variables, there are wood and configuration ...;%ang_home%/bin; ...
%PATH%= ... Maybe-OTHER-ENTRIES ...;%ANT_HOME%/Bin; ... Maybe-OTHER-ENTRIES ...
5. The operation of ANT
When ANT runs the command, sometimes there will be some Park JAR libraries. These libraries will exist in each ANT project, so at this time we can put this jar package into the ANT_HOME/LIB directory as a global library.
If you don't want to "pollute" the original ant program, then you can put jar package in the current Windows user directory. The specific location should be $ {user.home}/. ANT/lib. Without the above directory, it can be established manually.
If you just want to add lib temporarily and don't want to add LIB to the current ANT engineering. You can specify the dependent lib parameter when running the Ant program.
At the same time, you can also add your project to jar package in the current BUILD project's ClassPath directory.
6. Ant command
The grammatical element description is as follows:
-Help
Display the help information of the ant command and its options
-Projecthelp
The display contains the help document written by all users in the constructive file. That is, the text of the description attribute in each <TARGET>, and any text included in the <description> element. The target of the Description attribute is the main target (main target), and the target without this attribute is listed as a subtarget.
-Version
It is required to display its version information and then exit.
-quiet
Inhibition is not most of the news generated by the Echo task in the Construction File.
-verbose
Display the detailed messages of each operation during the construction process. This option can only be selected with the -DEBUG option.
-Debug
Show ANT and task developers have already marked messages to debug messages. This option can only choose one of them with -verbose.
-emacs
Format the log messages so that they can easily be analyzed by Emacs's shellmode; that is, printing task events, but not shrinking, nor [Taskname] before it.
-Logfile Filename
Reset the log output to the specified file.
-Logger ClassName
Specify a class to process the log of ANT. The specified class must implement Org.apache.Tools.ant.buildlogger interface.
-Listener ClassName
To declare a monitoring class and increase it to its listener list. This option is very useful when ANT and IDE or other Java programs are integrated. You can read Chapter 6 to understand more information about the supervisor. The specified listening class must be written as the processing of the construction message that can handle ANT.
-Buildfile Filename
Specify the construction file you need to process. The default construction file is build.xml.
-Dproperty = value
Define a characteristic name -value pair on the command line.
-Find FILENAME
Specify the construction file that should be processed. Unlike-Buildfile options, if the specified file is not found in the current directory, the -Find requires to search in its parent directory. This search will continue to be carried out in its ancestral directory until the root of the file system, and if the file has not been found, the construction fails.
-TuoProxy JDK1.5 or more can use agent settings
-NOUSERLIB does not use the jar package in the user lib when running
-NICE design main thread priority
-logfile uses the specified log log
-noinput does not allow interactive input
-KEEP -GOING, -k execution does not depend on all goals
-PROPERTYFIL
Copy code code as follows:
<project default = "all">
<property name = "pro_a" value = "a value" />
<property name = "pro_b" value = "b value" />
<path id = "rt.phth">
<Pathelement local = "$ {java.home} /jre/lib/rt.jar"/>
</PATH>
<target name = "all">
<javac srcdir = ".">
<classpath Refid = "A.path" />
</javac>
</target>
</project>
Notice:
● All constructive files must have <Project> elements, and at least one <TARGET> element.
● The default attribute for the <Project> element does not necessarily require the default value.
● Construction files do not have to be named Build.xml. But Build.xml is the default file name that ants want to search.
● Each construction file can only have one <Project> element.
Enter the current build.xml directory copy code in the CMD window as follows:
ant
Run ANT in Build.xml in the current directory to perform default targets.
Copy code code as follows:
Ant -Buildfile Build -test.xml
Run ANT in the Build-TEST.XML in the current directory to execute the default target.
Copy code code as follows:
Ant -Buildfile Build -Test.xml Clean
Run ANT in the BUILD-TEST.XML in the current directory, and execute a target called Clean.
Copy code code as follows:
Ant -Buildfile Build -Test.xml -DBuild = Build/Classes Clean
Run ANT in the BUILD-TEST.XML in the current directory, execute a target called Clean, and set the value of the Build attribute to Build/Classes.
7. ANT script: use nodes, elements and attributes, command instructions
1. Project node element
Project element is the root element of the Ant component file. The ant component file should contain at least one Project element, otherwise an error will occur. In each Project element, multiple target elements can be included. Next show readers the attributes of the Project element.
● Name attributes: the name for specifying the Project element.
● DEFAULT attribute: The name of the target execution of the dearget when the Project is executed by default.
● Basedir attribute: used to specify the position of the base path. When this attribute is not specified, the attachment of the Ant component file is used as the benchmark directory.
Copy code code as follows:
<? xml version = "1.0"?>
<project name = "ant-project" default = "print-dir" bases = ".">
<target name = "print-dir">
<echo message = "the base dia is: $ {basedir}" />
</target>
</project>
It can be seen from the above example that the value of the default property is print-dir here, that is, when the ANT command is running, if the target is not indicated, the default target (Print-Dir) will be executed. In addition, the value of the Basedir attribute is ".". It means the current directory. After entering the current directory, running the ANT command, and the result:
2. Target node element
Target is the basic execution unit or task of ANT, which can contain one or more specific units/tasks. Multiple targets can have mutual dependence. It has the following attributes:
● Name attribute: Specify the name of the target element, which is unique in a Project element. We can specify a target by specifying the name of the target element.
● DEPENDS attribute: It is used to describe the dependency relationship between targets. If there is a dependent relationship with multiple targets, you need to "," interval. ANT will execute each target according to the order of target in the depends property, and the dependent target will be executed first.
● IF attribute: It is used to verify that the specified attribute exists. If it does not exist, the target will not be executed.
● Unless attribute: The function of this attribute is the opposite of the function of the IF attribute. It is also used to verify whether the specified attribute exists. If it does not exist, the target will be executed.
● Description attribute: This attribute is a brief description and description of the target function.
Example:
Copy code code as follows:
<? xml version = "1.0"?>
<project name = "ant-timeget" default = "print">
<target name = "version" if = "ant.java.version">
<echo message = "java version: $ {ant.java.version}" />
</target>
<target name = "print" depends = "version" unless = "docs">
<description>
a Depending Example!
</description>
<echo message = "the base dia is: $ {basedir}" />
</target>
</project>
From the following results, we can see that we are running the target of Print. Since it depends on Version as the target task, Version will be executed first. At the same time Execute Version, output information: "[echo] java version: 1.6", after the Version is executed, then executes because DOCS does not exist, and the Unless attribute enters the target when there is no existence. It can be seen that print can execute execution , Output Information: "[Echo] The Base Dir is: D: D:/Workspace/Antexample/Build".
3. Property attribute node element
Property elements can be regarded as definition of parameters or parameters. Project's attributes can be set through the Property element or set outside ANT. If you want to introduce a file outside, such as Build.properties files, you can quote it by the following content:
<property file = "build.properties"/>/>
Property elements can be used as the attribute value of TASK. In TASK, it is achieved by placing attribute names between $ {attribute name} and placed in the position of the TASK attribute value.
ANT provides some built -in attributes. The list of system properties it can get is consistent with the attributes obtained by System.GetProperties () methods in the Java document. These system attributes can refer to the explanation of the SUN website. At the same time, ANT also provides some of its own built -in attributes, as follows:
Basedir: The absolute path of Project Base List;
Ant.file: The absolute path of Buildfile. In the above example, the ant.file value is D:/Workspace/ANTEXAMPLE/Build;
ant.version: Ant version information, this article is 1.8.1;
ant.project.Name: The name of the current specified Project, that is, the name property value of the project mentioned earlier;
Ant.java.version: The JDK version detected by ant, this article is 1.6.
For example, as follows:
Copy code code as follows:
<project name = "ant-project" default = "example">
<property name = "name" value = "jojo" />
<property name = "Age" value = "25" />
<target name = "example">
<echo message = "name: $ {name}, age: $ {age}" />
</target>
</project>
In the above example, the user sets two attributes named name and Age. After these two attributes are set, they can obtain these two attribute values through $ {name} and $ {Age}, respectively.
4. Copy command
Copy is mainly used to copy the file and directory. For example, as follows:
● Copy a single file:
Copy code code as follows:
<copy file = "old.txt" tofile = "new.txt"/>
● Copy the file directory:
Copy code code as follows:
<copy today = "../ Dest_dir">
<fileset dir = "src_dir"/>
</copy>
● Copy the file to another directory:
Copy code code as follows:
<copy file = "src.txt" todir = "c:/base"/>
5. Delete command
Delete the file or directory, as follows:
● Delete a file:
Copy code code as follows:
<delete file = "/res/images/cat.jpg"/>
● Delete a directory:
Copy code code as follows:
<delete dir = "/res/image"/>
● Delete all jar files or empty directory:
Copy code code as follows:
<delete includeemptydirs = "true">
<fileset dir = "." Includes = "**/*. jar"/>
</delete>
6. Mkdir command
Create a directory.
Copy code code as follows:
<mkdir dir = "/Home/Philander/Build/CLASSES"/>/>
7. MOVE command
Move files or directory, as follows:
● Move a single file:
Copy code code as follows:
<move file = "source" toFile = "Destfile"/>/>
● Move a single file to another directory:
Copy code code as follows:
<move file = "source" todir = "movedir"/>/>
● Move a directory to another directory:
Copy code code as follows:
<move today = "newdir">
<fileset dir = "olddir"/>
</move>
8. Echo command
The role of this task is to output information based on the level of the log or monitor. It includes four attributes: MESSAGE, FILE, APEND and Level.
<echo message = "ant message" file = "/logs/ant.log" append = "true">
9. JAR tag node element
This tag is used to generate a jar file, which is as follows.
● Destfile indicates the name of the jar file.
● Basedir represents the file name of the archived.
● Includes indicates the file mode of not archiving.
● EXCHUDES represents the excluding file mode.
● Compression indicates whether it is compressed.
Example:
Copy code code as follows:
<jar Destfile = "$ {webroot}/$ {ash_jar}" level = "9" compression = "true" enCoding = "uTF-8" basedir = "$ {Dest}">
<manifest>
<aTTRIBUTE NAME = "Implementation-Value =" Version: 2.2 "/>
</manifest>
</jar>
The above Mainfest is the contents of the file content in the manifest.mf in the Meat-inf in the jar package
The same packaging operation is War, TGZ, and the decompression operation UZIP
Copy code code as follows:
<!-Create zip->
<zip baseness = "$ {basedir}/class" zipfile = "temp/output.zip"/>/>
<!-Create TGZ->
<gzip src = "classes/**/*. class" zipfile = "output.class.gz"/>
<! --Coltage zip->
<Unzip src = "Output.class.gz" Dest = "Extractdir"/>
<!-Create war package->
<war Destfile = "$ {webroot} /ASH.WAR" BASEDIR = "$ {Basedir}/web" webxml = "$ {Basedir} /Web/web.xml">>
<exclude name = "web-inf/classs/**"/>
<exclude name = "web-inf/lib/**"/>
<exclude name = "web-inf/work/_jsp/**"/>
<lib dir = "$ {lib.dir}" includes = "**/*. jar, **/*. So, **/*. DLL">
<exclude name = "$ {webroot}/$ {HelloWorld_jar}"/>
</lib>
<lib file = "$ {webroot}/$ {helloword_jar}"/>
<classes dir = "$ {Dest}" includes = "**/*. Xml, **/*. Properites, **/*. XSD"> </classses>
</war>
10. Javac tag node element
The label is used to compile one or a group of java files, and its attributes are as follows.
● SRCDIR represents the directory of the source program.
● Destdir represents the output directory of the class file.
● Include represents the pattern of the compiled file.
● Excludes represents the pattern of files that is excluded.
● ClassPath represents the class path used.
● Debug represents debugging information.
● Optimize indicates whether to use optimization.
● Verbose represents detailed output information.
● Fileonerror said automatically stopped when it encountered an error.
Example Copy code code is as follows:
<javac srcdir = "$ {src}" destdir = "$ {Dest}"/>
<!- Set jvm memory
<javac srcdir = "src" fork = "true"/>
<javac srcdir = "src" fork = "true" executable = "d:/sdk141/bin/javac"
memorymaximumsize = "128m"/>
->
11. Java tag node element
This label is used to execute the .CLASS file that was compiled, and its attributes are as follows.
● ClassName represents the name of the execution.
● JAR means the name of the jar file containing this class.
● ClassPath expressed the class path used.
● Fork means running this class in a new virtual machine.
● Failonerror said automatically stopped when an error occurred.
● OUTPUT indicates the output file.
● APEND indicates addition or cover the default file.
Example Copy code code is as follows:
<java className = "com.hoo.test.Helloworm" classpath = "$ {hello_jar}"/>
12. ARG data parameter element
The program called by ANT can pass the command line parameters to it through the <RG> element, such as Apply, Exec, and Java tasks that can be accepted with nested <RG> elements, and can specify the specified parameters for their respective processes. Here are all the attributes of <ARG>.
● Values is a command parameter. If there is a space in the parameter, but if you want to use it as a single value, use this attribute.
● File represents a file name of a parameter. In the construction of a file, the name of this file is relative to the current working directory.
● LINE indicates multiple parameters of the space separated by spaces.
● Express the path, a Path-Like string that is used as a single command line variable; or as a separator, ANT will transform it into a separatist symbol of a specific platform.
● Pathref referenced Path (using PATH element node definition PATH) ID
● Prefix prefix ● Suffix suffix
Example Copy code code is as follows:
<arg value = "-la -a"/>
It is a single command line variable containing space.
Copy code code as follows:
<arg line = "-la -a"/>
It is the command line variable separated by two spaces.
Copy code code as follows:
<arg path = "/dir;/dir2:/dir3"/>
It is a command line variable, and its value is/dir;/dir2;/dir3 on the DOS system;/DIR:/DIR2:/DIR3 on the UNIX system.
13. Ericonment type
The external commands or programs called the file called by ANT, and the <ENV> element formulates which environment variables should be passed to the system commands that are being executed. <ENV> elements can accept the following attributes.
● File represents the file name of the ambient value value. The name of this file is a absolute path to be converted.
● PATH represents the path of the environment variable. ANT will convert it to a local agreement.
● Value represents a direct variable of the environment variable.
● Key means environmental variable name.
Pay attention to the File Path or Value that can only take one.
14. Filelist file collection list
FileList is a data type that supports naming file lists. The files containing in a FileList type do not necessarily exist. Here are all its attributes.
● DIR is a directory for calculating the absolute file name.
● FILES is a list of files separated by comma.
● Refid is a reference to a <filelist> defined in a certain place.
Note that DIR and Files are necessary, unless DIR and FILEs are not allowed to be used unless they are specified in this case).
Example Copy code code is as follows:
<filelist ID = "docfiles" dir = "$ {doc.src}" files = "foo.xml, bar.xml"/>
File collection $ {doc.src} /foo.xml and $ {doc.src} /bar.xml. These files may still not exist.
<filelist ID = "docfiles" dir = "$ {doc.src}" files = "foo.xml bar.xml"/>
<filelist refid = "docfiles"/>
<filelist ID = "docfiles" dir = "$ {doc.src}">
<file name = "foo.xml"/>
<file name = "bar.xml"/>
</filelist>
15. Fileset file type
The Fileset data type defines a set of files and is usually expressed as the <fileset> element. However, many ANT tasks have built hidden Fileset, which shows that they support all FileSet attributes and nested elements. The following is a list of attributes of Fileset.
● DIR represents the base directory of Fileset.
● If the value of the cases of cases is false, then when matched the file name, the fileset is not distinguished from the case, and its default value is true.
● DEFAULTEXCLUDES is used to determine whether to use the default exclusion mode, and the default is true.
● EXCLUDES is a file pattern list that needs to be sent with a comma separation.
● Excludesfile represents the file name of a file that contains a exclusion mode per line.
● Includes is separated by a comma, and the file pattern list that needs to be included.
● Includesfile means that each row includes a file name containing a mode.
Example Copy code code is as follows:
<fileset ID = "lib.runtime" dir = "$ {lib.path}/runtime">
<include name = "**/*. jar"/>
<include name = "**/*. so"/>
<include name = "**/*. dll"/>
</fileset>
<fileset ID = "lib.container" dir = "$ {lib.path}/container">
<include name = "**/*. jar"/>
</fileset>
<fileset ID = "lib.extras" dir = "$ {lib.path}">
<include name = "test/**/*. jar"/>
</fileset>
16. Patternset type
Fileset is a packet of files, and patterns are packed in patterns. They are closely related concepts.
<Patternset> supports 4 attributes: Includes, Excludex, IncludexFile, Excludesfile, which are the same as FileSet.
Patternset also allows the following nested elements: Include, Exclude, IncludeFile and Excludesfile.
Example Copy code code is as follows:
<!-Black and white list->
<Patternset id = "non.test.sources">
<include name = "**/*. java"/>
<!-The file name contains the exclusion of TEST->
<exclude name = "**/*test*"/>
</Patternset>
<Patternset ID = "Sources">
<include name = "std/**/*. java"/>
<!-Judging the condition that there is a propenerational to introduce->
<include name = "Prof/**/*. Java" if = "Professional"/>/>
<exclude name = "**/*test*"/>
</Patternset>
<!-A set of files->
<Patternset includesfile = "SOME-FILE"/>
<Patternset>
<includesfile name = "some-free"/>
<Patternset/>
<Patternset>
<includesfile name = "some-free"/>
<includesfile name = "$ {some-meher-file}" if = "some-mean-free"/>
<Patternset/>
17. Filterset type
Filterset defines a set of filters that replace the text of the file when the file moves or copys.
The main attributes are as follows:
● Begintoken indicates the mark searched by the nested filter, which is a string that identifies it.
● Endtoken indicates that the mark searched by the nested filter is a string that identifies its end.
● ID is the sole logo of the filter.
● Refid is a reference to a filter somewhere in the construction file.
Example Copy code code is as follows:
<!-@Date@is replaced by@date@to the current date of TODAY in the version.txt file content in the target file.
<copy file = "$ {build.dir} /version.txt" tofile = "$ {dist.dir} /Version.txt">
<filterset>
<filter token = "date" value = "$ {today}"/>
</filterset>
</copy>
<!-Custom variable format->
<copy file = "$ {build.dir} /version.txt" tofile = "$ {dist.dir} /Version.txt">
<!-Start searched from the%position in Version.txt to the end of the*position, and replace the@date@in the replacement content to the value of the current date of TODAY->
<filterset Begintoken = "%" Endtoken = "*">
<filter token = "date" value = "$ {today}"/>
</filterset>
</copy>
<!-Use external filter definition file->
<copy today = "$ {dist.dir}/docs">
<fileset dir = "$ {build.dir}/docs">
<include name = "**/*. html">
</fileset>
<filterset Begintoken = "%" Endtoken = "*">
<!--the attributes and values of the files are introduced from the outside, and the attributes and values of the coming
<filtersfile file = "$ {user.dir} /dist.properties"/>
</filterset>
</copy>
<!-Use the reference method, repeatedly use the filter set->
<filterset ID = "MyFilterset" Begintoken = "%" Endtoken = "*">
<filter token = "date" value = "$ {today}"/>
</filterset>
<copy file = "$ {build.dir} /version.txt" tofile = "$ {dist.dir} /Version.txt">
<filterset refid = "myfilterset"/>
</copy>
18. Path type
PATH elements are used to represent a class, but it can also be used to represent other paths. When used as a few attributes, the various scores or colons in the road scripture are separated. When constructing, this separator will replace all the path separators on the current platform, and its attributes are as follows.
● Location represents a file or directory. ANT expands this into an absolute path internally.
● Refid is a reference to a PATH defined in the current constructive file.
● PATH indicates a file or path list.
Example Copy code code is as follows:
<path id = "buildpath">
<fileset Refid = "lib.runtime"/>
<fileset Refid = "lib.container"/>
<fileset Refid = "lib.extras"/>
</PATH>
<path id = "src.paths">
<fileset ID = "srcs" dir = ".">
<include name = "src/**/*. java"/>
</fileset>
</PATH>
8. The code code of the compilation of packing and running engineering is as follows: as follows:
<? xml version = "1.0" encoding = "UTF-8"?>
<!--name is the name of the current project. Default is the default task. Basedir is the working directory (. Represents the current root directory)->
<project name = "HelloWorld" DEFAULT = "Run" Basedir = ".">
<!-Property is similar to a simple variable in the program->
<propoperty name = "src" value = "src"/>
<property name = "dest" value = "class"/>
<property name = "Hello_jar" value = "HelloWorld.jar"/>
<!--
Target is an event, event, task, name is the name of the current thing. Depends is the last one or multiple things. If the dependence is not executed, ANT will run the dependence first, and then run the current thing.
->
<!-initialization->
<target name = "init">
<! --Classes directory->
<mkdir dir = "$ {Dest}"/>
<mkdir dir = "temp"/>
<mkdir dir = "temp2"/>
</target>
<!-Compilation->
<target name = "compile" depends = "init">
<javac srcdir = "$ {src}" destdir = "$ {Dest}"/>
<!- Set jvm memory
<javac srcdir = "src" fork = "true"/>
<javac srcdir = "src" fork = "true" executable = "d:/sdk141/bin/javac"
memorymaximumsize = "128m"/>
->
</target>
<!-<<建->
<target name = "build" depends = "compile">
<!--
<jar jarfile = "$ {hello_jar}" basedir = "$ {Dest}"/>
Create a name for Package.jar file
<jar Destfile = "Package.jar" Basedir = "Classes"/>
->
<jar Destfile = "$ {hello_jar}" basedir = "classses">
<!-Add content to the main file in the jar package->
<manifest>
<aTTRIBUTE NAME = "Built-By" Value = "$ {User.name}"/>
<aTTRIBUTE NAME = "Main-Class" Value = "Package.main"/>/>
</manifest>
</jar>
<!-Copy jar file todir = "Copy to the directory"->
<copy file = "$ {Hello_jar}" Tofile = "$ {Dest} /temp.jar"/>
<copy todir = "test">
<!-DEFAULTEXCLUDES = ""->
<fileset dir = "src">
<include name = "**/*. java"/>
</fileset>
</copy>
<copy todir = "temp2">
<fileset dir = "src">
<AND>
<contain text = "main"/>
<size value = "1" when = "more"/>
</and>
</fileset>
</copy>
<!-Mobile jar file->
<move file = "$ {Dest} /temp.jar" toFile = "Temp/Move-temp.jar"/>
<!-Create zip->
<zip baseness = "$ {basedir}/class" zipfile = "temp/output.zip"/>/>
<!-Create TGZ->
<gzip src = "classses/**/*. class" zipfile = "output.class.gz"/>
<! --Coltage zip->
<Unzip src = "Output.class.gz" Dest = "Extractdir"/>
<! --- replace the OLD in the content of input.txt content to NEW
<replace file = "input.txt" token = "old" value = "new"/>
->
</target>
<! --- Run->
<target name = "run" depends = "build">
<java className = "com.hoo.test.Helloworm" classpath = "$ {hello_jar}"/>
</target>
<!-Clear->
<target name = "clear">
<!-Deleted the generated file->
<delete dir = "$ {Dest}"/>
<delete file = "$ {hello_jar}"/>
</target>
<TSTAMP>
<FORMAT Property = "Offset_time"
pattern = "hh: mm: ss"
Offset = "10" unit = "minute"/>
</tStamp>
<!-Restart->
<target name = "raun" depends = "Clean, Run">
<echo message = "### $ {tStamp}#$ {today}#$ {dstamp} ###"/>
<likeing target = "cLEAN"/>
<likeing target = "run"/>
</target>
</project>
There are basically so many things to say. There are still many contents of ANT. If you are interested, you can study it yourself. Ant is not difficult. You use it to enter the command line at the DOCS console, but ANT is a script information that converts the command line to XML, which can be repeatedly run. Under certain circumstances, efficiency and repeated work have been improved.