Ode to Build Scripts

DZone 's Guide to

Ode to Build Scripts

· ·
Free Resource
I was reading the Code to Joy blog today because of an interesting blog entry about Groovy and JFugue, who are two of my friends in the programming world. It's very cool to see how they relate: simplified Java with simplified Midi! The best of both worlds. In the comments Guillaume from Groovy writes: "A couple years ago, I played with the idea of an Ant build listener that played JFugue little tunes when certain targets were started and finished, to have an audible indication of what was going on."

And then I remembered my recent explorations of the org.apache.tools.ant.module.spi.AntLogger class. That, according to the Javadoc is "a pluggable logger that can listen to AntEvents during one or more AntSessions". You can incorporate that into a NetBeans module, install it in NetBeans IDE, and then the IDE (being modular) is influenced by the installed module. So, inspired by Guillaume, here is my JFugified Antlogger:

public class SuccessfulBuildLogger extends org.apache.tools.ant.module.spi.AntLogger {

public boolean interestedInSession(AntSession session) {
return true;

public boolean interestedInAllScripts(AntSession session) {
return true;

public void buildFinished(AntEvent event) {
Throwable t = event.getException();
Player player = new Player();
if (t != null) {
//There is an exception, so write message and play notes:
event.getSession().println(t.toString(), true, null);
Pattern pattern1 = new Pattern("I[60] E E F G");
} else {
//Play different notes when there is no exception:
Pattern pattern2 = new Pattern("I[60] G F E D");


The above implies I have a NetBeans module suite (which is a container for modules), which in this case contains a library wrapper for JFugue, together with a functionality module that provides the above class. I've extended the module so that the user can use the NetBeans IDE Options window to type in a different pattern of JFugue notes (even with syntax coloring and code completion, in a JEditorPane), but I encountered a problem with JFugue that I'm trying to get fixed first. Something about a sequencer not being found. I think in the past that meant that I needed to restart, or something like that, or maybe my disk is full, or something like that.

Anyway, I now hear one pattern when the build succeeds and another when it fails, for every project in NetBeans IDE. Hurray!



Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}