Ode to Build Scripts
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 {
@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 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!




