1

I am creating an eclipse plugin to do both git clone & import together.

My code snippet for the eclipse import as bellow:

        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());

This is working, but it's creating another copy of our cloned project, at workspace.

Is there any way to do something like, Import without "copying projects into workspace"?

Tharaka Deshan
  • 1,349
  • 3
  • 15
  • 30
  • so: basically, you want to import something that doesn't exist yet, and have eclipse "know" where this non-existing project in the future will exist? – Stultuske Jan 03 '18 at 11:14
  • Sorry for the confusion. I don't want to copy the original project folder to the workspace. – Tharaka Deshan Jan 03 '18 at 11:21
  • yes, I know what you mean. but the point is: how can eclipse import anything that is nowhere on your drive (yet) because you still have to clone it? – Stultuske Jan 03 '18 at 11:23
  • No I have them cloned in the previous step and the are on the drive now. It's should similar to, importing existing projects using import wizard with unchecking "copy projects into workspace" option. where it is not copying the to workspace but have a link – Tharaka Deshan Jan 03 '18 at 11:28
  • why not ask in eclipse fora if someone there knows how that import is done? – Stultuske Jan 03 '18 at 11:30

1 Answers1

0

You can try to set ImportOperation.setCreateLinks(true) before you run the operation:

importOperation.setCreateLinks(true);
importOperation.run(new NullProgressMonitor());
KompjoeFriek
  • 3,572
  • 1
  • 22
  • 35