Apache Ant Introduction

Source: Internet
Author: User

Apache Ant, a tool for automating software compilation, testing, deployment, and more, is mostly used for software development in Java environments.

Ant is written in the pure Java language, so it has a good cross-platform nature. Simple to operate. Ant is made up of a built-in task and optional tasks. The ant runtime requires an XML file (build file). Ant can execute various tasks by invoking the target tree. Each task implements a specific interface object. Because the ant build file is a file in XML format, it is easy to maintain and write, and the structure is clear.

When you start a new project, you should first write the ant build file. The ant build file is named Build.xml by default, or it can take other names. The build file can be placed in any location. The general practice is to put it in the top-level directory of the project. This will keep the project concise and clear.

Ant has the following two advantages.

    • Using Java development, and storing build information with XML, is therefore cross-platform.
    • Programmers can extend ant themselves. Programmers can write their own Java programs to extend Ant and create their own tasks.

A typical project hierarchy:

(1) src deposit file.

(2) class holds the compiled file.      (3) Lib holds third-party jar packages. (4) Dist Storage package, post code. Each build file defines a unique project (project Element). Many goals (target elements) can be defined under each project, and there can be dependencies between those goals. When such goals are implemented, the goals that they depend on are enforced. Multiple tasks can be defined in each target, and the task sequence to be executed is also defined in the target. Ant must invoke the defined task when building the target. 1.<project> tag Each build file corresponds to one project. The <project> tag is the root tag of the build file. 2.<target> tags you can have one or more target tags under a project tab. A target tag can depend on other target tags. The ant's Depends property specifies the order in which target is executed. Ant executes each target sequentially, in the order in which the target appears in the Depends property. Before executing, you first need to execute the target that it depends on. 3.<mkdir> label This tag is used to create a directory, which has a property dir is used to specify the name of the directory created, the code is as follows: <mkdir dir= "${class.root}"/>4<jar> Label this tag is used to generate a JAR file 5. <javac tags > This tag is used to compile one or a set of Java file 6. <java> tags This tag is used to perform a compile-generated. class file 7.<delete> tag that is used to delete a file or a set of files 8.<copy> label this label is used for a copy of a file or set of files 9.<exec > Execution Files

Apache Ant Introduction

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.