Ant Learning -001-ant Basics and Windows environment configuration

Source: Internet
Author: User

I. ANT Overview Basics

Apache Ant is a tool that automates the process of software compilation, testing, deployment, and so on, mostly for software development in the Java environment, for building applications, or in conjunction with other open-source testing tools such as Git, testng, etc. to build a continuous integration test development environment that is efficient and High-quality building products.

Ant has some of the following advantages:

    1. Cross-platform, portable. Ant is written in the Java language, so it has good cross-platform and portability, whether it's on Windows, Linux, or Mac.
    2. Simple to operate. Ant is made up of a built-in task and optional task that requires a build file (Build.xml) that can perform various tasks (task) by invoking the target tree, while each task implements a specific interface object.
    3. Easy to maintain. The Ant build file (Build.xml) is an XML-formatted file that is easy to maintain and write because of its clear and concise structure. The build file can be placed anywhere and is usually recommended to be placed in the root of the project to keep the project concise and clear.

Typically, the typical hierarchy of Ant build projects is:

    • SRC: Storing source files
    • Classes: Storing compiled bytecode files
    • LIB: Storage of third-party jar packages
    • Dist: Storing compiled packages, and post-release code

The Ant build file is an XML file. Each build file defines a unique project (project Element). There are many goals (target elements) that can be defined under each project, and these targets may have dependencies between them. 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. Tasks define the commands that Ant actually executes, and the tasks are categorized into the following categories:

    1. Core tasks: Ant comes with tasks
    2. Optional tasks: For third-party tasks, additional jar files are required
    3. Custom tasks: User-defined tasks, tasks developed for the user

Second, Windows environment construction

1.Ant Downloads

Enter the Apache ant download page, as shown below, and select the appropriate Ant file download (select Windows Zip here) from the platform:

After successful download, unzip to the local folder, for example: D:\envConfig\apache-ant-1.9.6, unzip the directory structure as follows:

1 Ant2+---README, LICENSE, fetch.xml, other text files.//Ant basic Information3+---Bin//include some startup scripts, etc.4|5+---Lib//contains the jar and its dependencies required by Ant6|7+---Docs//documentation, user manuals, etc.8| |9| +---Images//pictures in documents, user manualsTen| | One| +---Manual//User Manual (Must-read) A| -+---etc//XLS related (create enhanced reports, output from different tasks; Migrate build files, avoid outdated warnings, etc.)

2.ANT environment variable Configuration

Add: ant_home=d:\envconfig\apache-ant-1.9.6 to the system variable to start the script to find the appropriate library file

In the path variable, add: path=%ant_home%\bin;%path%

At the same time the user needs to configure Jdk,java_home primarily used to load JDK/JRE after startup, see JAVA Learning -001-JDK installation configuration for how to configure the JDK

3.ANT Verification

Start Command Line window input command: Ant, you will get the following information hint:

Buildfile:build.xml does not exist! Build failed

At this point, it can be said that the ant Windows environment has been configured successfully, the reason for the above hint is that the ant's Build file Build.xml is missing. To see the version of Ant, you can enter: ant-version in the command Line window, as shown here:

Apache Ant (TM) version 1.9.6 compiled on June 29 2015

  

At this point, ant learning -001-ant basic knowledge and the Windows environment configuration successfully completed, I hope this article can give you a reference to learn ant.

Finally, very grateful to the pro-stop, I hope this article can be pro helpful. Warmly welcome the kiss to discuss together and progress together. Thank you so much! ^_^

Ant Learning -001-ant Basics and Windows environment configuration

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.