gpt4 book ai didi

java - 以编程方式将现有项目导入 Eclipse

转载 作者:搜寻专家 更新时间:2023-10-30 21:08:52 24 4
gpt4 key购买 nike

我正在尝试以编程方式将项目导入到 Eclipse 中。我不想使用 UI 模式。

下面是我用于导入项目的代码:

IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(  new Path("PROJECT_PATH/.project"));
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
project.create(description, null);
project.open(null);

我只得到项目文件夹以及.location 文件.markers.snap 文件和.syncinfo.snap 文件,但我没有得到源文件夹等。

最佳答案

使用 org.eclipse.ui.wizards.datatransfer.ImportOperation

尝试这样的事情:

IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
public String queryOverwrite(String file) { return ALL; }
};

String baseDir = // location of files to import
ImportOperation importOperation = new ImportOperation(project.getFullPath(),
new File(baseDir), FileSystemStructureProvider.INSTANCE, overwriteQuery);
importOperation.setCreateContainerStructure(false);
importOperation.run(new NullProgressMonitor());

关于java - 以编程方式将现有项目导入 Eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12401297/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com