O'Reilly logo

Ant: The Definitive Guide, 2nd Edition by Steve Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10. Optional Tasks

A significant number of optional tasks come with Antthe full list appears in Table 1-5and you’ll see several of them in this chapter. Some of the optional tasks are specialized, but a number are useful in everyday builds. You’ve seen optional tasks like junit and ftp, and this chapter expands that coverage with a look at tasks like sound, splash, replaceregexp, and depend.

Using Sound

The sound task plays a sound-file at the end of the build according to whether the build failed or succeeded. You can specify one sound file to play, or if you specify a directory, the sound task will randomly select a sound file to play.

Warning

If you’re using Java 1.3 or later, you need the Java Media Framework on the classpath (javax.sound).

The sound task can contain success and fail elements. The success element specifies the sound you want played if the build succeeds and failures the sound if it fails. Here’s an example where the build file specifies the sounds to play depending on if the build succeeded or failed:

<target name="sounds">
    <sound>
        <success source="${user.home}/sounds/success.wav"/>
        <fail source="${user.home}/sounds/noway.wav"/>
    </sound>
</target>

These success and failure elements support the attributes you see in Table 10-1.

Table 10-1. The success and fail elements’ attributes

Attribute

Description

Required

Default

source

Specifies the name of a sound file

Yes

 

loops

Specifies the number of times to play the sound file

No

0

duration

Specifies the time ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required