How do I get <javac> to list each file that it is compiling?

Gary Taylor

I have now written my own ant logger class to filter out all verbose messages except for the "File(s) to be compiled" message, which lists them all. Here is my code; if anyone wants to use it, feel free.

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.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact