I am using xmltask in my own custom ant task.  I have a couple problems I can't 
fix.


I'm not exactly sure how to create a new XmlTask.  I tried: XmlTask xml_edit = 
(XmlTask) project.createTask("xmltask");

The Eclipse IDE says the above "project" is depreciated.  What else would I use 
there?

I also added a taskdef that was called xmltask to my build.xml for my custom 
script:


                


I'm writing a task called: versionupdatetask, and here's the error I get when I 
run my code:

[versionupdatetask] java.lang.NullPointerException
[versionupdatetask]     at src.VersionUpdateTask.updateXML(Unknown Source)
[versionupdatetask]     at src.VersionUpdateTask.do_update(Unknown Source)
[versionupdatetask]     at src.VersionUpdateTask.execute(Unknown Source)
[versionupdatetask]     at org.apache.tools.ant.UnknownElement.execute(UnknownEl
ement.java:275)
[versionupdatetask]     at org.apache.tools.ant.Task.perform(Task.java:364)
[versionupdatetask]     at org.apache.tools.ant.Target.execute(Target.java:341)
[versionupdatetask]     at org.apache.tools.ant.Target.performTasks(Target.java:
369)
[versionupdatetask]     at org.apache.tools.ant.Project.executeSortedTargets(Pro
ject.java:1216)
[versionupdatetask]     at org.apache.tools.ant.Project.executeTarget(Project.ja
va:1185)
[versionupdatetask]     at org.apache.tools.ant.helper.DefaultExecutor.executeTa
rgets(DefaultExecutor.java:40)
[versionupdatetask]     at org.apache.tools.ant.Project.executeTargets(Project.j
ava:1068)
[versionupdatetask]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
[versionupdatetask]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
[versionupdatetask]     at org.apache.tools.ant.launch.Launcher.run(Launcher.jav
a:246)
[versionupdatetask]     at org.apache.tools.ant.launch.Launcher.main(Launcher.ja
va:67)
[versionupdatetask] update failed.

What am I doing wrong?  I'm using the attr ability of xmltask.  It's basically 
in this format:


    


But using java, I'm doing the following:

XmlTask xml_edit = (XmlTask) project.createTask("xmltask");
Attr xml_attr = xml_edit.createAttr();
xml_attr.setPath(xpath);
xml_attr.setAttr("value");
xml_attr.setValue(new_val);
FileSet xmlSet = new FileSet();
xmlSet.setFile(new File(file_path));
xmlSet.setDefaultexcludes(false);
xml_edit.addFileset(xmlSet);
xml_edit.execute();

Problem as you can see, xml_edit (which is an XmlTask) isn't even linked to 
xml_attr.  So how do I execute the attr function?

Thanks in advance
--
Sent from the Ant - Dev forum at Nabble.com:
http://www.nabble.com/Help-Running-Ant-Task-from-my-Custom-Task-%28xmltask%29-t235448.html#a658453

Reply via email to