I need to run an ANT build using the build.xml file that is stored inside the jar file. This jar file is available on the classpath. Is it possible to do it, without exploding the jar file and saving the build.xml to local directory? If so how can I do it.
Update:
The jar file is a ant build project where a build.xml in classpath is run via a java program using ANT libraries. The front end is a web application, which loads this build project jar as a dependency. A user will click a Build App button to run the ANT build. So I need to run the build.xml file in a jar when user clicks Build App.
Code for reading the build.xml file
URL preBuildFileUrl = getClass().getClassLoader().getResource("build.xml");
Project p = new Project();
p.setUserProperty("ant.file", preBuildFileUrl.toURI().getPath());
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, new File(preBuildFileUrl.toURI().getPath()));
p.executeTarget(p.getDefaultTarget());