ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rhino" <>
Subject Fun with Ant: Sound task
Date Fri, 16 Dec 2005 15:37:00 GMT
I don't know if anyone is remotely interested but I have created a bit of 
common code for playing sound files as part of the Sound task in Ant.

Here's how it gets used. Within each of my build scripts, I include these 

 Import common code. 
<property name="import.path" value="${ant.home}\imports"/>
<import file="${import.path}\sounds.xml" description="Play appropriate 
sounds depending on whether build worked or failed."/>

This code refers to a new directory, called 'imports', that I created within 
the ${ant.home} directory. Within the 'imports' directory, I have the 
- a file called 'sounds.xml'
- a file called ''
- a directory called 'Sounds'; this directory contains two directories of 
its own, 'Success' and 'Failure'
- the 'Success' directory contains a variety of .wav files that denote 
success in some fashion; you are free to use any files you like but I use 
cartoon clips like Daffy Duck saying "Ingenuity triumphs every time!"
- the 'Failure' directory contains a variety of .wav files that denote 
failure in some fashion; you are free to use any files you like but I use 
cartoon clips like Homer Simpson saying "D'oh!"

This is the contents of the sounds.xml file:

<?xml version="1.0" ?>
<project name="Sounds" default="end" basedir=".">
<description>This fragment will be imported into every Ant build
script that needs to play different sounds for success or failure
of the build.

<property name="properties.path" value="${ant.home}\imports"/>
<property file="${properties.path}\"/>

<sound description="Play success or failure sounds, whichever is 
 <success source="${sound.success}"/>
 <fail source="${sound.failure}"/>

<target name="end" description="Do nothing."/>


This is the contents of the file:

#These are the success and failure sounds to be played by Ant scripts.
# To play a specific sound file, specify the file path in full, e.g. 
# To play *any* sound file from a given directory, specify the directory, 
e.g. C:\\Windows\\Media
# Lines beginning with # (like this one) are comments


Whenever I install a new version of Ant, I simply copy my 'imports' 
directory and all its subdirectories over to my new Ant, then modify the 
values for sound.success and sound.failure in the '' file 
to point to the correct path. That's pretty much the only maintenance you 
have to do on this and I think you'll agree that is pretty trivial.

You are free to put any .wav files you like into the 'success' and 'failure' 
directories. Well-chosen sound files can entertain you and the people around 
you; one of my friends howled with laughter when he heard the file that 
played upon completion of one of my scripts :-)

I just thought I'd share this with the rest of the Ant community in case 
anyone was inclined to try something like this themselves.


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.1/204 - Release Date: 15/12/2005

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message