ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 53831] calling antcall from <script> throws a java.lang.NullPointerException
Date Wed, 05 Sep 2012 14:10:43 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=53831

--- Comment #1 from Antoine "hashar" Musso <hashar@free.fr> ---
I found a bug report in Groovy detailing a similar issue
http://jira.codehaus.org/browse/GROOVY-1506 . 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 {
            task.execute();
        } catch(err) {
            task.log( "Execution error: " + err.message );
        }

        ]]></script>
    </target>

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

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

</project>
The resulting execution is:

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

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

antcall:
     [echo] [antcall] succeed

BUILD SUCCESSFUL
Total time: 0 seconds
\O/

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

Mime
View raw message