Summary: | calling antcall from <script> throws a java.lang.NullPointerException | ||
---|---|---|---|
Product: | Ant | Reporter: | Antoine "hashar" Musso <hashar> |
Component: | Optional Tasks | Assignee: | Ant Notifications List <notifications> |
Status: | NEW --- | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Attachments: |
working build file
failing build file |
Description
Antoine "hashar" Musso
2012-09-05 14:10:14 UTC
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/ See also: http://stackoverflow.com/questions/12280295 Source code: https://gist.github.com/3636007 To clone the build script: git clone git://gist.github.com/3636007.git bug53831 git checkout 9e686eb # failing build.xml git checkout 3bb9964 # working file Created attachment 29334 [details]
working build file
Created attachment 29335 [details]
failing build file
|