Ant Building Blocks

With XML elements and tags, we can look at the primary components of an Ant buildfile as components or building blocks. We build the buildfile using these blocks. Some pieces have very specialized uses, while others are more common and used more frequently. Let's look at the primary components of the Ant buildfile. .1 The Project We call the set of tags and elements in an XML file from the root element — in this case <project> — to the lowest-nested tag, the document object model (or DOM). The first or root element of any buildfile is always the <project> tag. No buildfile can be without one, nor can it have more than one. The DOM lays elements out in a tree-like hierarchy, making the buildfile more of an object model than simply a plain process-description document. The following example shows a valid project tag: <project name="MyProject" default="all" basedir="."> . </project> The <project> tag has three attributes: name, default, and basedir. The name attribute gives the project a name. A project name is valuable for purposes of identifying log output (to know what project you're building). For systems that manage buildfiles, such as an IDE that can read buildfiles, the project name acts like an identifier for the buildfile. The default attribute refers to a target name within the buildfile. If you run Ant without specifying a target on the command line, Ant executes the default target. If the default target doesn't exist, Ant returns an error. While we do not recommend it, the value of default does not have to be a valid target name (i.e., a name corresponding to an actual target name in the buildfile). We suggest either making the default target compile everything or display help for using the buildfile. The basedir attribute defines the root directory of a project. Typically, it is ".", the directory in which the buildfile resides, regardless of the directory you're in when you run Ant. However, basedir can also define different points of reference. For example, a buildfile that is part of a hierarchical project structure needs a different reference point, referring to the project's root directory. You can use the basedir to specify this point of reference

pdf32 trang | Chia sẻ: tlsuongmuoi | Lượt xem: 2350 | Lượt tải: 0download
Bạn đang xem trước 20 trang tài liệu Ant Building Blocks, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên

Các file đính kèm theo tài liệu này:

  • pdfAnt Building Blocks.pdf
Tài liệu liên quan