use of org.eclipse.m2e.core.internal.preferences.MavenConfigurationImpl in project eclipse.jdt.ls by eclipse.
the class MavenProjectImporter method importToWorkspace.
@Override
public void importToWorkspace(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
JavaLanguageServerPlugin.logInfo(IMPORTING_MAVEN_PROJECTS);
MavenConfigurationImpl configurationImpl = (MavenConfigurationImpl) MavenPlugin.getMavenConfiguration();
configurationImpl.setDownloadSources(true);
configurationImpl.setNotCoveredMojoExecutionSeverity(ProblemSeverity.ignore.toString());
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
subMonitor.setTaskName(IMPORTING_MAVEN_PROJECTS);
Set<MavenProjectInfo> files = getMavenProjectInfo(subMonitor.split(5));
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
Collection<IProject> projects = new LinkedHashSet<>();
Collection<MavenProjectInfo> toImport = new LinkedHashSet<>();
long lastWorkspaceStateSaved = getLastWorkspaceStateModified();
// Separate existing projects from new ones
for (MavenProjectInfo projectInfo : files) {
File pom = projectInfo.getPomFile();
IContainer container = root.getContainerForLocation(new Path(pom.getAbsolutePath()));
if (container == null) {
toImport.add(projectInfo);
} else {
IProject project = container.getProject();
if (ProjectUtils.isMavenProject(project)) {
projects.add(container.getProject());
} else if (project != null) {
// Project doesn't have the Maven nature, so we (re)import it
toImport.add(projectInfo);
}
}
}
if (!toImport.isEmpty()) {
ProjectImportConfiguration importConfig = new ProjectImportConfiguration();
configurationManager.importProjects(toImport, importConfig, subMonitor.split(75));
}
subMonitor.setWorkRemaining(20);
updateProjects(projects, lastWorkspaceStateSaved, subMonitor.split(20));
subMonitor.done();
}
Aggregations