ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Cuprak <507...@corpmail.kodak.com>
Subject [FIX?] Re: Bug in Ant? - More information (examined source and modified)
Date Fri, 04 Oct 2002 19:55:48 GMT
I think I have come up with a way to fix things although it is more of 
a kludge in my book. I would appreciate it if others could check the 
effect this has on their code and make sure it does not have any 
adverse effect!! I made the modifications to the 1.5.1 downloadable 
from ant's website - I had done a cvs checkout yesterday from home but 
although it compiles, ant doesn't work, complains about a missing 
fileset or something, so don't try this with a fresh cvs checkout! This 
appears to fix the problem- my tasks do execute now!

-Ryan Cuprak

To RuntimeConfigurable.java add the following:
    public Object getWrappedObject () {
        return ( wrappedObject );
    }

To Target.java erase the exisiting execute method and add the following:
    public void execute() throws BuildException {
        if (testIfCondition() && testUnlessCondition()) {
            Enumeration enum = children.elements();
            while (enum.hasMoreElements()) {
                Object o = enum.nextElement();
                if (o instanceof Task) {
                    Task task = (Task) o;
                    task.perform();
                } else {
                    RuntimeConfigurable r = (RuntimeConfigurable) o;
                    r.maybeConfigure(project);
                    Object t = r.getWrappedObject();
                    if ( t instanceof Task ) {
                        System.err.println ( "Going to execute: " + t );
                        try {
                            project.fireTargetStarted(this);
                            Task t2 = (Task)t;
                            t2.execute();
                            project.fireTargetFinished(this, null);
                        } catch (RuntimeException exc) {
                            project.fireTargetFinished(this, exc);
                            throw exc;
                        }

                    }
                }
            }
        } else if (!testIfCondition()) {
            project.log(this, "Skipped because property '"
                        + project.replaceProperties(this.ifCondition)
                        + "' not set.", Project.MSG_VERBOSE);
        } else {
            project.log(this, "Skipped because property '"
                        + 
project.replaceProperties(this.unlessCondition)
                        + "' set.", Project.MSG_VERBOSE);
        }
    }
On Friday, October 4, 2002, at 02:44 PM, Ryan Cuprak wrote:

>
> Trying to track down this problem, I modified Target.java with 
> System.err statements to check variable types. Basically, if I run the 
> task directly, o is an instance of Task but if I run utilities-build 
> via antcall, my AntTask is no longer a 'Task' but a 
> RuntimeConfigurable.  Does anyone have any insights as to why my task 
> becomes typed differently depending on whether antcall is used versus 
> directly running the task?
>
>  -Ryan
> (Target.java)
> public void execute() throws BuildException {
>         if (testIfCondition() && testUnlessCondition()) {
>             Enumeration enum = children.elements();
>             while (enum.hasMoreElements()) {
>                 Object o = enum.nextElement();
>                 System.err.println ( "O: " + o );
>                 if (o instanceof Task) {
>                     System.err.println ( "is a task." );
>                     Task task = (Task) o;
>                     task.perform();
>                 } else {
>                     System.err.println ( "is not a task." );
>                     RuntimeConfigurable r = (RuntimeConfigurable) o;
>                     r.maybeConfigure(project);
>                 }
>             }
>         } else if (!testIfCondition()) {
>             project.log(this, "Skipped because property '" + 
> this.ifCondition
>                 + "' not set.", Project.MSG_VERBOSE);
>         } else {
>             project.log(this, "Skipped because property '"
>                 + this.unlessCondition + "' set.", 
> Project.MSG_VERBOSE);
>         }
>     }
>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message