我需要使用存储在JAR文件中的build.xml文件来运行ANT构建。该JAR文件位于类路径上。是否可以在不展开JAR文件并将build.xml保存到本地目录的情况下执行此操作?如果可以,我该如何做。
更新:
该JAR文件是一个ANT构建项目,其中通过使用ANT库从类路径中运行build.xml的Java程序。前端是一个Web应用程序,它将此构建项目JAR作为依赖项加载。用户将单击Build App按钮以运行ANT构建。因此,当用户单击Build App时,我需要在JAR中运行build.xml文件。
读取build.xml文件的代码:
更新:
该JAR文件是一个ANT构建项目,其中通过使用ANT库从类路径中运行build.xml的Java程序。前端是一个Web应用程序,它将此构建项目JAR作为依赖项加载。用户将单击Build App按钮以运行ANT构建。因此,当用户单击Build App时,我需要在JAR中运行build.xml文件。
读取build.xml文件的代码:
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());