【问题标题】:Eclipse : Programmatically importing projects without copyingEclipse:以编程方式导入项目而不复制
【发布时间】:2018-01-03 22:30:57
【问题描述】:

我正在创建一个 Eclipse 插件来同时执行 git clone 和导入。

我的eclipse导入代码sn-p如下:

        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);
        IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
            public String queryOverwrite(String file) {
                return ALL;
            }
        };


        ImportOperation importOperation = new ImportOperation(project.getFullPath(), new File(PROJECT_PATH),
                FileSystemStructureProvider.INSTANCE, overwriteQuery);
        importOperation.setCreateContainerStructure(false);
        importOperation.run(new NullProgressMonitor());

这是可行的,但它正在工作区创建我们克隆项目的另一个副本。

有没有什么方法可以做类似的事情,导入而不“将项目复制到工作区”?

【问题讨论】:

  • so:基本上,你想导入一些还不存在的东西,并且让 eclipse “知道”这个不存在的项目将来会存在哪里?
  • 很抱歉给您带来了困惑。我不想将原始项目文件夹复制到工作区。
  • 是的,我知道你的意思。但关键是:eclipse 怎么能导入任何在你的驱动器上不存在的东西(还),因为你仍然需要克隆它?
  • 不,我在上一步中克隆了它们,现在它们在驱动器上。它应该类似于使用导入向导导入现有项目并取消选中“将项目复制到工作区”选项。它不是将工作区复制到工作区,而是有一个链接
  • 为什么不在 Eclipse 论坛中询问是否有人知道导入是如何完成的?

标签: java eclipse eclipse-plugin


【解决方案1】:

您可以在运行操作之前尝试设置ImportOperation.setCreateLinks(true)

importOperation.setCreateLinks(true);
importOperation.run(new NullProgressMonitor());

【讨论】:

    猜你喜欢
    • 2016-10-23
    • 2012-09-06
    • 1970-01-01
    • 2010-09-20
    • 2020-03-15
    • 2013-02-23
    • 1970-01-01
    • 1970-01-01
    • 2017-08-26
    相关资源
    最近更新 更多