Java Share 20th day (Build.xml syntax and notation)

Source: Internet
Author: User

Typically, the ant build file build.xml should be in the project's underlying directory. You can freely use other file names or other locations in the build file.
In this exercise, create a file named Build.xml anywhere on your computer.
<?XML version= "1.0"?>   <Projectname= "Hello World Project"default= "Info">   <Targetname= "Info">      <Echo>Hello World-welcome to Apache ant!</Echo>   </Target></Project>
Note that there should be no empty lines or spaces before the XML declaration. The processing instruction target matching "[Xx][mm][ll]" is not allowed-if you do this, this may be caused by an error message when you run the ant build.
All build files require project elements and at least one target element.
The XML element's project has three properties:

A goal is a collection of tasks to run as a unit. In our example, we have a simple goal to provide an informational message to the user.
The target can be dependent on other targets. For example, a deployment target might have dependencies on encapsulated objects and package targets that might have dependencies on compile targets, and so on. Dependencies are expressed using dependency properties. For example:
<target name= "Deploy" depends= "pacakge" >
....
</target>
<target name= "pacakge" depends= "Clean,compile" >
....
</target>
<target name= "clean" >
....
</target>
<target name= "Compile" >
....
</target>
The target element has the following properties:


The Echo task in the example above is to print a message for a simple task. In our example, it prints out the Hello World message.
To run the ant build file, open a command prompt and navigate to the folder where the Build.xml file is located, and then enter Ant info. You can also just enter ant instead. Both work because the information is the default target in the build file. You should see the following output:

Java Share 20th day (Build.xml syntax and notation)

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.