ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <>
Subject RE: How to silence javac task?
Date Fri, 11 Aug 2006 11:37:12 GMT

a look into source of javac task source shows
4 locations where log(...) is used =

public String getCompiler() {
        String compilerImpl = getCompilerVersion();
        if (fork) {
            if (isJdkCompiler(compilerImpl)) {
                compilerImpl = "extJavac";
            } else {

// *** 1. only logged if loglevel warning or higher

                log("Since compiler setting isn't classic or modern,"
                    + "ignoring fork setting.", Project.MSG_WARN);
        return compilerImpl;

    protected void compile() {
        String compilerImpl = getCompiler();

        if (compileList.length > 0) {

// *** 2. always logged as no leglevel specified

            log("Compiling " + compileList.length + " source file"
                + (compileList.length == 1 ? "" : "s")
                + (destDir != null ? " to " + destDir : ""));

            if (listFiles) {
                for (int i = 0; i < compileList.length; i++) {
                  String filename = compileList[i].getAbsolutePath();

// *** 3. always logged as no leglevel specified


            CompilerAdapter adapter =
                CompilerAdapterFactory.getCompiler(compilerImpl, this);

            // now we need to populate the compiler adapter

            // finally, lets execute the compiler!!
            if (!adapter.execute()) {
                if (failOnError) {
                    throw new BuildException(FAIL_MSG, getLocation());
                } else {

// *** 4. logged if failonerror="true" used and an error occurs
                    log(FAIL_MSG, Project.MSG_ERR);

So 2. and 3. are _always_ logged irrespective of used loglevel
it's like using System.out and setloglevel has no impact.

maybe you could change 2. and 3. to log(... , Project.MSG_DEBUG);   
then it should only appear with <setloglevel level="debug" />

Regards, Gilbert

-----Original Message-----
From: Hans Schwaebli [] 
Sent: Friday, August 11, 2006 1:14 PM
To: Ant Users List
Subject: RE: How to silence javac task?

setloglevel doesn't work. If I use it, the errors are not shown. Javac
treats warnings and errors the same, both are error stream.
  Can you tell me if and how I could use a log filter?
  Then I would filter the lines from javac which must not be logged.

"Rebhan, Gilbert" <> wrote:

the idea for setting the loglevel via task is not mine,
read about some time ago in a blog, 
but i don't remember where.

i only had to edit the setLevel() method to make it work, 
simply used the method from$EchoLevel

i also think that this little task should be part of ant.
We use it quit often for chatty :-) tasks.

Regards, Gilbert

-----Original Message-----
From: Steve Loughran [] 
Sent: Tuesday, August 08, 2006 11:28 PM
To: Ant Users List
Subject: Re: How to silence javac task?

Hans Schwaebli wrote:
> This solution seems to work, thanks. But I have to test it a little
bit more. If a compile error occurs, the error message must be logged.
> I wished that this task would be a standard Ant task (out of the box).

Probably because most people werent aware it was that much of an issue, 
primarily because most projects try and control the errors from javac, 
or to fiddle with javac settings. javac is extra chatty, though it 
doesnt tell you off as much as jikes1.2.1 did.

It could -maybe- become a task, though it would need tests first.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message