Ode to Build Scripts

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 {

    @Override
    public boolean interestedInSession(AntSession session) {
        return true;
    }

    @Override
    public boolean interestedInAllScripts(AntSession session) {
        return true;
    }

    @Override
    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");
            player.play(pattern1);
        } else {
            //Play different notes when there is no exception:
            Pattern pattern2 = new Pattern("I[60] G F E D");
            player.play(pattern2);
        }
    }

}

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!

Comments:

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!"

Posted by Seapegasus on February 17, 2008 at 05:36 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today