Ant command line operation
The ant build file can be compiled, packaged, and tested. It is a sub-project in the Jakarta folder of the Apache Software Foundation. It is cross-platform, easy to use, and easy to use.
For ant execution, you can find build. XML in the project for direct execution, and switch to the build file folder for execution in the command line. The former is faster than the worker, while the latter is slower. You can run ant by entering the ant command in the command line. If no worker number is specified, ant will search for build in the current folder. XML file. If the file is found, the file is executed. If the file is not found, the system prompts that the relevant build is not found. XML file.
Project View:
Code List:
Build. xml
<? XML version = "1.0" encoding = "UTF-8"?> <Project name = "myant" default = "" basedir = "."> <description> simple example Build File </description> <! -- Define the project source file storage path --> <property name = "srcdir" location = "src"/> <! -- Define the path for storing project compilation files --> <property name = "builddir" location = "bin"/> <! -- Define the path to the project package file --> <property name = "distdir" location = "Dist"/> <! -- Initial project file --> <target name = "init" If = "ant. java. version "Unless =" argmin "> <tstamp> <format property =" offset_time "pattern =" HH: mm: SS "offset =" 10 "unit =" Minute "/> </tstamp> <mkdir dir =" $ {builddir} "/> <mkdir dir =" $ {distdir }" /> <echo message = "creating the compiling folder .... "/> </Target> <! -- Compile the project file --> <target name = "compile" depends = "init" Description = "compile the source"> <javac srcdir = "$ {srcdir}" destdir =" $ {builddir} "DEBUG =" false "fork =" true "/> <echo message =" compiling the file folder .... "/> </Target> <! -- Package the project source file --> <target name = "Dist" depends = "compile" Description = "generate the distribution"> <jar basedir = "$ {builddir}" destfile = "$ {distdir}/package-$ {dstamp }. jar "update =" true "> <manifest> <attribute name =" built-by "value =" $ {user. name} "/> <attribute name =" Main-class "value =" package. main "/> </manifest> </jar> <jar basedir =" $ {srcdir} "destfile =" $ {distdir}/package-Src-$ {dstamp }. jar "update =" true "/> <EC Ho message = "Packaging and compiling files, source file..."/> </Target> <! -- Clear the project package --> <target name = "clean" Description = "Clean Up"> <Delete dir = "$ {builddir}"/> <Delete dir = "$ {distdir} "/> <echo message =" Clear the compilation folder, source folder... "/> </Target> </Project>
Ant command list:
Generally, an ant command is composed of the following:
Ant-arguments [target1, TARGET2, target3, target4......]
1, ant-H
Purpose: provides the ant command for Batch Tasks.
2, ant-projecthelp |-P
Purpose: display the main tasks of the current build. xml
3, ant-version
Purpose: display the latest ant version.
4, ant-Diagnostics
Purpose: diagnose all configurations of the current ant
5, ant-Debug |-d
Purpose: retrieve the configuration of the current Build File
6, ant-Quiet |-Q
Purpose: display that the current build file has no dependency tasks
7, ant-Emacs |-e
Purpose: Call the editor to edit the current build file.
8, ant-lib [path]
Purpose: Call the jar and class files of the current project.
9, ant-logfile |-l
Purpose: Call and execute the *. log file in the current project.
10, ant-buildfile |-f |-File
Purpose: call a file similar to build. xml.
11, ant-propertyfile [name]
Purpose: Call and execute the specified property file.
12, ant-find |-s file
Purpose: retrieve and execute the specified Build File
13, ant-autoproxy
Purpose: use the system's own active proxy to build a file
14, ant-Main class
Purpose: set the main classes in the system library file.
15, ant-Nice number
Purpose: set the number of threads agreed by the main thread.
These ant commands are frequently used and hope to help you!