[Ant] [Startwithant] The first chapter a simple ant example

Source: Internet
Author: User
Tags echo message

Click here to download startwithant full PDF document and code: http://download.csdn.net/detail/sodino/6603769


Ant, a tool that links software compilation, testing, deployment, and other steps together to automate software development in Java environments.

I use Ant's scene is to take it in the background to compile, packaging Android project operations, during ant work, still can use ecelipse, avoid painful waiting.

Before using it, you should download ant and deploy the execution environment, which is the process of adding system environment variables in detail, as follows: Ant installation, environment variable configuration and validation.

An example of ant is given below:

[HTML] view plain copy <?xml version= "1.0" encoding= "UTF-8"?> <project name= "Hello_world" default= "Ec Ho "basedir=". " > <target name= "Echo" description= "Just print ' Hello world '." > <echo message= "Hello world! I ' m ant. " ></echo> </target> </project> Code 1.1 Hello World

Ant does not define its own syntax, and its executable file is written in XML.

The above code is stored in the file build_01_hello_world.xml. Executing the file requires the following command:

Ant–f Build_01_hello_world.xml, the operation effect is as follows:


Figure 1.1 Hello World

After executing the command, the first line shows the absolute path of the compiled file, and the "Echo:" After a space line indicates that the target name of the current execution is "echo"; [Echo] "indicates that the current output was initiated by the Ant's Echo Task (Task). Finally, the prompt for "BUILD successful" and the amount of time spent executing are given.

An easier way to execute the ant build file is to name the build file Build.xml, which can be run as long as the command line ant is executed in the same directory as the build file.




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.