private GradleImportOperation createImportOperation(IProgressMonitor m) throws FastOperationFailedException, OperationCanceledException, CoreException { m.beginTask("Create re-import operation", 1); try { GradleRefreshPreferences prefs = gradleProjects.iterator().next().getRootProject().getRefreshPreferences(); List<HierarchicalEclipseProject> projects = new ArrayList<HierarchicalEclipseProject>(gradleProjects.size()); Set<HierarchicalEclipseProject> relatedProjectsSet = new HashSet<HierarchicalEclipseProject>(); for (GradleProject gradleProject : gradleProjects) { projects.add(gradleProject.getGradleModel(m)); relatedProjectsSet.addAll(gradleProject.getAllProjectsInBuild()); } GradleImportOperation op = new GradleImportOperation( projects, false, GradleImportOperation.createProjectMapping( prefs.getUseHierarchicalNames(), Arrays.asList( relatedProjectsSet.toArray( new HierarchicalEclipseProject[relatedProjectsSet.size()])))); op.setQuickWorkingSet(null); // this option only meaningfull on initial import. op.setReimport(true); op.verify(); return op; } finally { m.done(); } }
private boolean haveGradleModel() { try { return project != null && project.getGradleModel() != null; } catch (FastOperationFailedException e) { } catch (CoreException e) { GradleCore.log(e); } return false; }