Professional Java Tools for Extreme Programming [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional Java Tools for Extreme Programming [Electronic resources] - نسخه متنی

Richard Hightower, Warner Onstineet al.

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید











Basics of Using Ant

This section is a quick tutorial covering the basics of Ant. You will learn about projects, targets, properties, tasks, filesets, pathelements, and other key concepts. Upon completion of this chapter, you should understand Ant well enough to write your own Ant buildfiles.


Projects, Targets, and Tasks


Ant's build scripts, called buildfiles, are written in XML. Every buildfile contains one project element. A project element contains target elements. Each target consists of a set of task elements.

A task performs a function such as copying a file, compiling a project, or creating a JAR file.

A target is a collection of tasks and properties. A target can depend on other targets, meaning that a target does not execute until the targets it depends on are executed (for example, you would normally want to compile classes before you put them in a JAR). To indicate that a target depends on another target, you use the depends attribute. Thus, you may have something like the set of targets in the following listing (we left out the tasks associated with the targets; we'll cover them later).

The project is a group of related targets. Although you can define any target you like, a set of standard naming conventions exists, as we discuss in the section “Standard Targets.”

<project name="myproject" default="all" basedir=".">
<target name="all" depends="clean,fetch,build,test,docs,deploy">
...
</target>
<target name="clean" >
...
</target>
<target name="fetch" >
...
</target>
<target name="build" depends="clean" >
...
</target>
<target name="test" depends="build" >
...
</target>
<target name="docs" depends="clean" >
...
</target>
<target name="deploy" depends="build, test" >
...
</target>
<target name="publish" depends="deploy" >
...
</target>
</project>

This listing contains a build target that could, for example, compile the source and create JAR and WAR files. Notice that the build target depends on the execution of the tasks associated with the clean target (the tasks are not shown). The test target in turn depends on the build target. The order of the dependencies expressed with the target's “depend” attribute in this example is quite logical. For example, you can't test the code if it does not build—after the code is built, it's tested.

You can give targets any name that you like. However, people generally use common Ant names to create buildfiles, as discussed in the next section.

/ 228