【发布时间】:2016-11-21 00:14:25
【问题描述】:
我正在开发一个需要附带内置 ant 构建文件的 Eclipse 插件。它在我运行项目时工作。但是,当我在另一个 Eclipse 中导出插件并部署导出的插件时,没有生成 ant 构建文件。我的怀疑是在运行时,没有访问ant构建文件的源。任何指针如何解决这个问题?这是代码:
private void createAntFile(IProject project, Properties properties) throws CoreException, IOException {
InputStream antFileInputStream =null;
try {
String antFileName = properties.getProperty("name.ant.file");
String antFilePath = properties.getProperty("path.ant.file");
IFile file = project.getFile(antFileName);
antFileInputStream = Activator.getDefault().getBundle().getEntry(antFilePath).openStream();
file.create(antFileInputStream, false, null);
antFileInputStream.close();
}finally{
if(antFileInputStream!=null){
try {
antFileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
name.ant.file=build.xml
path.ant.file=src/weblogic/ant/build.xml
我在路径src/weblogic/ant/build.xml中硬编码的源码构建文件
编辑:
这是创建内置文件夹的代码:
private void createWeblogicTemplate(IProject project, Properties properties) throws IOException, CoreException {
String weblogicTemplateSourcePath = properties.getProperty("path.weblogic.template.source");
Path path = new Path(weblogicTemplateSourcePath);
Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
URL fileURL = FileLocator.find(bundle, path, null);
String filePath = FileLocator.resolve(fileURL).getPath();
System.out.println(filePath);
File sourceFile = new File(filePath);
String weblogicTemplateTargetPath = properties.getProperty("path.weblogic.template.target");
IFolder folder = project.getFolder(weblogicTemplateTargetPath);
copyFolder(sourceFile,folder,project,properties);
}
System.out.println(filePath) 行打印路径为 /C:/Users//Desktop/eclipse-rcp-luna-SR2-win32-x86_64/eclipse/../../../workspace-plugin/weblogic/resources/weblogictemplate/
所以,它在本地工作。但是,当我在其他 Eclipse 中部署 pluin 时,它不起作用。任何指针如何创建内置文件夹?
【问题讨论】:
标签: eclipse eclipse-plugin eclipse-rcp