[英]calling ant script file from Java class itself
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. 我有一个查询-我有一个名为abc.xml
的单独的XML文件,它是其中包含蚂蚁任务的XML文件。 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
? 现在我可以通过Eclipse的是它不同的任务,我可以执行,但现在我正打算是我能够执行从Java类本身并从主方法的Java类中执行该XML执行从蚂蚁角度看该文件abc.xml
? please advise, is it possible to call the ant script file that is in form of an xml file through itself 请告知,是否可以通过本身调用xml文件形式的ant脚本文件
I was also going through run ant manually 我也手动进行过run ant
I have separate task named as init in the abc.xml
file 我在abc.xml
文件中有一个名为init的单独任务
what i have tries in side the main method of java class is 我在旁边尝试的Java类的主要方法是
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
. 可以在ant-launcher.jar
找到org.apache.tools.ant.launch.Locator
类。 Check CLASSPATH of your porgram and make sure ant-launcher.jar
and other required jars are available. 检查您的Porgram的CLASSPATH ,并确保ant-launcher.jar
和其他必需的jar可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.