ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [Bug 53831] calling antcall from <script> throws a java.lang.NullPointerException
Date Wed, 05 Sep 2012 14:10:43 GMT

--- Comment #1 from Antoine "hashar" Musso <> ---
I found a bug report in Groovy detailing a similar issue . The attached patch by Andreas
Sahlbach fixed the groovy issue by assigning an owner to a newly created task.

So I have gone ahead and added:

task.setOwningTarget( self.getOwningTarget() );
That fixed the issue. I have put the original script and the fixed one in gist
3636007 so other people can play with.

Final script is below:

<project default="main">
    <target name="main">
        <script language="javascript"> <![CDATA[
        task = project.createTask( 'macro' );

        if( task.getOwningTarget() == null ) {
            task.log( "Assigning an owner ..." );
            task.setOwningTarget( self.getOwningTarget() );
            task.log( "Task:  " + task.getOwningTarget() );

        try {
        } catch(err) {
            task.log( "Execution error: " + err.message );


    <macrodef name="macro">
            <antcall target="antcall" />

    <target name="antcall">
        <echo>[antcall] succeed</echo>

The resulting execution is:

$ ant
Buildfile: /Users/amusso/ant/bug/build.xml

    [macro] Assigning an owner ...
    [macro] Task:  main

     [echo] [antcall] succeed

Total time: 0 seconds

You are receiving this mail because:
You are the assignee for the bug.

View raw message