I have a query that is - I have a separate xml file named abc.xml
which is an xml file having ant tasks in it. Now i can execute that file from ant perspective through eclipse that is it different tasks i can execute but, now what i am planning is to execute that xml from the java class itself and from the main method inside that java class can i execute that abc.xml
? please advise, is it possible to call the ant script file that is in form of an xml file through itself
I was also going through run ant manually
I have separate task named as init in the abc.xml
file
what i have tries in side the main method of java class is
File buildFile = new File("abc.xml");
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
but the error that i am getting is..
Exception in init: org/apache/tools/ant/launch/Locator
at org.apache.tools.ant.util.FileUtils.fromURI(FileUtils.java:1261)
at org.apache.tools.ant.Location.<init>(Location.java:87)
at org.apache.tools.ant.Location.<init>(Location.java:70)
at org.apache.tools.ant.helper.ProjectHelper2$ProjectHandler.onStartElement(ProjectHelper2.java:611)
at org.apache.tools.ant.helper.ProjectHelper2$RootHandler.startElement(ProjectHelper2.java:465)
The class org.apache.tools.ant.launch.Locator
can be found in ant-launcher.jar
. Check CLASSPATH of your porgram and make sure ant-launcher.jar
and other required jars are available.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.