You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Rhino <rh...@sympatico.ca> on 2005/12/16 16:37:00 UTC

Fun with Ant: Sound task

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 
lines:



<!--=============================================================
 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 
following:
- a file called 'sounds.xml'
- a file called 'sounds.properties'
- 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.
</description>

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

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

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

</project>
---------------------------------------------------------------------------------------

This is the contents of the sounds.properties file:

----------------------------------------------------------------------------------------
#These are the success and failure sounds to be played by Ant scripts.
#
#NOTES:
# To play a specific sound file, specify the file path in full, e.g. 
C:\\Windows\\Media\\sir.wav
# 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

sound.success=d:\\Ant\\apache-ant-1.6.5\\imports\\Sounds\\Success
#sound.success=d:\\Ant\\apache-ant-1.6.5\\imports\\Sounds\\Success\\sir.wav
sound.failure=d:\\Ant\\apache-ant-1.6.5\\imports\\Sounds\\Failure
#sound.failure=d:\\Ant\\apache-ant-1.6.5\\imports\\Sounds\\Failure\\ALLWRONG.wav
----------------------------------------------------------------------------------------

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 'sounds.properties' 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.

Rhino



-- 
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Fun with Ant: Sound task

Posted by Rhino <rh...@sympatico.ca>.
----- Original Message ----- 
From: "Emmanouil Batsis" <Em...@eurodyn.com>
To: "Ant Users List" <us...@ant.apache.org>
Sent: Friday, December 16, 2005 11:23 AM
Subject: Re: Fun with Ant: Sound task


> Rhino wrote:
>
>> 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.
>
>
> Pretty cool, thanks for sharing!
>
You're very welcome; enjoy!

Rhino 



-- 
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Fun with Ant: Sound task

Posted by Emmanouil Batsis <Em...@eurodyn.com>.
Rhino wrote:

> 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. 


Pretty cool, thanks for sharing!

MAnos

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org