ant-user mailing list archives

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

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

                  log(filename);
                }
            }

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

            // now we need to populate the compiler adapter
            adapter.setJavac(this);

            // 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 [mailto:hans_schwaebli@yahoo.com] 
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" <Gilbert.Rebhan@huk-coburg.de> wrote:
  
Hi,

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 org.apache.tools.ant.taskdefs.Echo$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 [mailto:stevel@apache.org] 
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message