Ant command-line Operations

Source: Internet
Author: User
Tags echo message

Ant command-line Operations

The ant build file compiles, packages, and tests the project, a sub-project in the Apache Software Foundation Jakarta folder that is cross-platform, simple to use, and very easy to get started with.

About ant execution, the ability to find build.xml directly in the project, and the ability to switch to the build file folder execution at the command line. The former is faster, while the latter is relatively slow, the ant command can be executed on the command line, and if no number of parameters are specified, Ant will retrieve the Build.xml file under the current folder, assuming that the file was found and executed, assuming that it was not found and that the relevant Build.xml file was not found.

Project View:

Code Listing:

Build.xml

<?xml version= "1.0" encoding= "UTF-8"? ><project name= "Myant" default= "" basedir= "." > <description> Simple Example Build file </description> <!--define project source files to store the path--<property name= " Srcdir "location=" src "/><!--define the project compilation file storage path--<property name=" BuildDir "location=" Bin "/><!-- Define project package file storage path--<property name= "Distdir" location= "Dist"/><!--Initial Project class 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 compilation Folder ..."/> </target> < Compiling project class files---<target name= "compile" depends= "init" description= " Compile the source "> <javac srcdir=" ${srcdir} "destdir=" ${builddir} "debug=" false "fork=" true "/> <echo mess Age= "Compiling Files folder ..."/> </target> <!--packaging project source Files--<target name= "Dist" depends= "Compile "description=" generate the Distribution "> <jar basedir=" ${builddir} "destfile=" ${distdir}/package-${ds Tamp}.jar "update=" true "> <manifest> <attribute name=" built-by "value=" ${user.name} "/> <attribu Te name= "Main-class" value= "package. Main "/> </manifest> </jar><jar basedir=" ${srcdir} "destfile=" ${distdir}/package-src-${dstamp}.ja R "update=" true "/> <echo message=" is packaging compiled files, source files ... "/> </target> <!--purge Project packages--<target name=" Clean "description=" \ Up "> <delete dir=" ${builddir} "/> <delete dir=" ${distdir} "/> <echo message= "Empty compilation folder, source Folder ..."/> </target></project>

The ant command List explains specifically:

In general, an ant command is executed, and its composition is:

ant-arguments [Target1,target2,target3,target4 ...]

1,ant-h

Function: Indicates an ant command-count task

2,ant-projecthelp | -P

Function: Displays the main tasks of the current Build.xml

3,ant-version

Function: Displays the latest version number of the current ant

4,ant-diagnostics

Function: Diagnose the full configuration of the current ant

5,ant-debug | -D

Role: Retrieving the current Build file configuration

6,ant-quiet | -Q

Function: Displays the current build file without dependent tasks

7,ant-emacs | -E

Role: Invoke edit Current Build file Editor

8,ant-lib [path]

Function: Invokes the Jar,class file in the current project

9,ant-logfile |-l

Function: Call to execute the *.log file in the current project

10,ant-buildfile |-F | -file

Function: Invoke a file that performs similar build.xml

11,ant-propertyfile [Name]

Function: Invokes execution of the specified property file

12,ant-find | -S file

Function: Retrieves the execution of the specified build file

13,ant-autoproxy

Role: Build files using the system's own active agent

14,ant-main class

Function: Set the main class in the System class library file

15,ant-nice number

Role: Sets the number of threads agreed by the main class thread

These ant commands are often used and hope to help you!

Ant command-line Operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.