Files | Admin

Notes:

Release Name: Antwrap 0.6.0

Notes:
    * The Antwrap syntax has changed. Prior to version 0.6.0, any blocks passed in with a task were evaluated within the context of the task itself (using :instance_eval), so there was no AntProject instance passed to the block. For example, when the path task block was evaluated, it was evaluated within the context of the path task, so the pathelement children were assumed to be child tasks;


@ant.path(:id => "other.class.path"){      
    pathelement(:location => "classes")    
    pathelement(:location => "config")   
}
                                    
This approach is pleasing syntactically because it looks like the XML syntax we are accustomed to. Unfortunately, it means that you can't execute arbitrary code in the block. For example, this would fail because the AntTask class does not contain a foobar() method;

def foobar                                             
    return "classes"                                 
end                                                      
                                                           
@ant.path(:id => "other.class.path"){        
    foo = foobar()                                    
    pathelement(:location => foo)              
    pathelement(:location => "config")    
}                                    

To rectify this, the AntProject now yields to the block and passes itself as a parameter. So calling your foobar() method will work;

def foobar
    return "classes"
end

@ant.path(:id => "other.class.path"){ |ant|
    foo = foobar()  
    ant.pathelement(:location => foo)
    ant.pathelement(:location => "config")
}

While slightly more verbose, this changes make life easier when invoking Ant tasks, and is more typical of a Ruby library.


Changes: