How do I get <javac> to list each file that it is compiling?
Created May 14, 2012
import org.apache.tools.ant.*;
public class CompileListLogger extends DefaultLogger {
public void messageLogged(BuildEvent event) {
// Send on all ERR, WARN, and INFO messages.
// For VERBOSE or DEBUG, look for task "javac".
// Look for "File(s) to be compiled" message.
// When found, send it on.
// Ignore everything else.
boolean ignore = false;
if (event.getPriority() >= Project.MSG_VERBOSE) {
ignore = true;
if (event.getTask() != null) {
String name = event.getTask().getTaskName();
if (name.equals("javac")) {
String msg = event.getMessage();
if (msg.startsWith("File to be compiled") ||
msg.startsWith("Files to be compiled")) {
ignore = false;
}
}
}
}
if (!ignore) {
super.messageLogged( event );
}
}
}
Be sure to invoke ant with the -verbose option as well as the -logger option.