Source:
public static void createProjects(final Set<ProjectRecord> projectsToCreate, final boolean open, final IWorkingSet[] selectedWorkingSets, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IWorkspaceRunnable wsr = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor actMonitor) throws CoreException { IWorkingSetManager workingSetManager = PlatformUI.getWorkbench() .getWorkingSetManager(); actMonitor.beginTask("", projectsToCreate.size() * 2 + 1); if (actMonitor.isCanceled()) { throw new OperationCanceledException(); } Map<IProject, File> projectsToConnect = new HashMap<>(); SubMonitor progress = SubMonitor.convert(actMonitor, projectsToCreate.size() * 2 + 1); for (ProjectRecord projectRecord : projectsToCreate) { if (actMonitor.isCanceled()) { throw new OperationCanceledException(); } actMonitor.subTask(projectRecord.getProjectLabel()); IProject project = createExistingProject(projectRecord, open, progress.newChild(1)); if (project == null) { continue; } RepositoryFinder finder = new RepositoryFinder(project); finder.setFindInChildren(false); Collection<RepositoryMapping> mappings = finder .find(progress.newChild(1)); if (!mappings.isEmpty()) { RepositoryMapping mapping = mappings.iterator().next(); IPath absolutePath = mapping.getGitDirAbsolutePath(); if (absolutePath != null) { projectsToConnect.put(project, absolutePath.toFile()); } } if (selectedWorkingSets != null && selectedWorkingSets.length > 0) { workingSetManager.addToWorkingSets(project, selectedWorkingSets); } } if (!projectsToConnect.isEmpty()) { ConnectProviderOperation connect = new ConnectProviderOperation( projectsToConnect); connect.execute(progress.newChild(1)); } } }; try { ResourcesPlugin.getWorkspace().run(wsr, monitor); } catch (OperationCanceledException e) { throw new InterruptedException(); } catch (CoreException e) { throw new InvocationTargetException(e); } }

Target:
public static void createProjects(final Set<ProjectRecord> projectsToCreate, final boolean open, final IWorkingSet[] selectedWorkingSets, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IWorkspaceRunnable wsr = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor actMonitor) throws CoreException { IWorkingSetManager workingSetManager = PlatformUI.getWorkbench() .getWorkingSetManager(); if (actMonitor.isCanceled()) { throw new OperationCanceledException(); } Map<IProject, File> projectsToConnect = new HashMap<>(); SubMonitor progress = SubMonitor.convert(actMonitor, projectsToCreate.size() * 2 + 1); for (ProjectRecord projectRecord : projectsToCreate) { if (progress.isCanceled()) { throw new OperationCanceledException(); } progress.setTaskName(projectRecord.getProjectLabel()); IProject project = createExistingProject(projectRecord, open, progress.newChild(1)); if (project == null) { continue; } RepositoryFinder finder = new RepositoryFinder(project); finder.setFindInChildren(false); Collection<RepositoryMapping> mappings = finder .find(progress.newChild(1)); if (!mappings.isEmpty()) { RepositoryMapping mapping = mappings.iterator().next(); IPath absolutePath = mapping.getGitDirAbsolutePath(); if (absolutePath != null) { projectsToConnect.put(project, absolutePath.toFile()); } } if (selectedWorkingSets != null && selectedWorkingSets.length > 0) { workingSetManager.addToWorkingSets(project, selectedWorkingSets); } } if (!projectsToConnect.isEmpty()) { ConnectProviderOperation connect = new ConnectProviderOperation( projectsToConnect); connect.execute(progress.newChild(1)); } } }; try { ResourcesPlugin.getWorkspace().run(wsr, monitor); } catch (OperationCanceledException e) { throw new InterruptedException(); } catch (CoreException e) { throw new InvocationTargetException(e); } }