Is it possible to load a macrodef in a subproject and have it usable in the
calling project?
I've got a task flow that's roughly:
ParentProject calls load target on SubProject.
SubProject loads antlib containing macrodefs.
ParentProject calls loaded macro.
I know this isn't supported as part of core Ant, so I created a task
patterned after the antcontrib AntFetch task, except I'm copying back all
the new references and task definitions instead of properties.
This allows me to invoke the macro from the ParentProject, but I get a
NullPointerException in the MacroInstance class.
java.lang.NullPointerException
at
org.apache.tools.ant.taskdefs.MacroInstance.getNsElements(MacroInstan
ce.java:98)
at
org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.jav
a:338)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Walking through the debugger, the created MacroInstance has no MacroDef
saved on it, which is supposed to happen at create time.
I'm assuming the reason this isn't working is because I'm passing the task
definition back to the ParentProject instead of the actual created
MacroInstance. Does that make sense?
Is it possible to do what I'm attempting, or do I need to revamp my design?
Thanks for the help,
Dan Turkenkopf