Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#22 foreach: Incorrect task name reported for javac from foreach

closed-fixed
Matt Inger
None
5
2003-03-04
2003-01-29
John Meagher
No

When invoking a javac task through a foreach task the
javac output is reported as coming from foreach instead
of javac.

Also if the javac is done within a <record> block that
compile output is not sent to the record log.

Attached is a sample build.xml and .java file that
illustrate the problem.

The output I get from it is as follows:

Buildfile: build.xml

init:

test:

_local:
[echo] Testing local echo
[javac] Compiling 1 source file to
D:\Meagher\Projects\metamorph\test\ant
[foreach]
D:\Meagher\Projects\metamorph\test\ant\Test.java:3:
invalid method declaration; return type required
[foreach] public static main( String args[] )
[foreach] ^
[foreach]
D:\Meagher\Projects\metamorph\test\ant\Test.java:6:
cannot resolve symbol
[foreach] symbol : variable outttt
[foreach] location: class java.lang.System
[foreach] System.outttt.println( "Hello World" );
[foreach] ^
[foreach] 2 errors
[javac] Compile failed; see the compiler error
output for details.

BUILD SUCCESSFUL
Total time: 1 second

I expected the [foreach] to instead be [javac]. And
the only thing logged to the file is:

[echo] Testing local echo
[javac] Compiling 1 source file to
D:\Meagher\Projects\metamorph\test\ant
[javac] Compile failed; see the compiler error
output for details.

Discussion

  • John Meagher
    John Meagher
    2003-01-29

    File showing the problem.

     
    Attachments
  • John Meagher
    John Meagher
    2003-01-29

    Logged In: YES
    user_id=521186

    Oops, the file didn't attach before.

     
  • John Meagher
    John Meagher
    2003-01-30

    Logged In: YES
    user_id=521186

    Oops. Attached the wrong jar file

     
  • John Meagher
    John Meagher
    2003-01-30

    The real file showing the problem

     
    Attachments
  • John Meagher
    John Meagher
    2003-01-30

    Logged In: YES
    user_id=521186

    Upon further investigation into this I found the problem is
    the handleOutput and handleErrorOutput that the ForEach task
    is inheriting from Task.

    It looks like Ant had the same problem in the CallTarget
    class (see its overrided handle...Output methods. The
    problem with the ForEach task is that the CallTarget left
    the handle methods a protected so they can't be invoked the
    same way as is done with the callee object in the
    CallTarget class.

    I've added a patch for the ForEach task that will work after
    the handle methods in CallTarget are made public.

    Patch:
    http://sourceforge.net/tracker/index.php?func=detail&aid=677682&group_id=36177&atid=416922

     
  • John Meagher
    John Meagher
    2003-01-31

    Logged In: YES
    user_id=521186

    Update: The Ant code was changed to make the needed methods
    public. The change will be available in 1.5.2.

     
  • Matt Inger
    Matt Inger
    2003-03-04

    Logged In: YES
    user_id=83032

    The requested changes have been made to the ForEach task.

     
  • Matt Inger
    Matt Inger
    2003-03-04

    • assigned_to: nobody --> mattinger
    • status: open --> closed-fixed
     
  • Matt Inger
    Matt Inger
    2003-03-04

    Logged In: YES
    user_id=83032

    forgot to mention the changed file:

    net/sf/antcontrib/logic/ForEach.jvaa