Geertjan's Blog

  • January 22, 2008

Ode to Build Scripts

Geertjan Wielenga
Product Manager
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". 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 suite, which 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!

Join the discussion

Comments ( 1 )
  • Seapegasus Monday, February 18, 2008

    I read a scifi story that reminded me of this... O_O The head technician of a confined space colony had mapped notes to control structures and states of his maintenance programs, so he could track the system state without looking. The next generation of children in the colony habitually whistled the "tunes", and over time the whistling became part of the language... :-) So in the future, young developers will whistle "E E F G!!", and their mothers will say "Watch your mouth!"

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.