use of org.eclipse.m2e.core.project.MavenProjectInfo 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();
}
use of org.eclipse.m2e.core.project.MavenProjectInfo in project liferay-ide by liferay.
the class MavenUtil method importProject.
public static List<IMavenProjectImportResult> importProject(String location, IProgressMonitor monitor) throws CoreException, InterruptedException {
MavenModelManager mavenModelManager = MavenPlugin.getMavenModelManager();
IWorkspaceRoot workspaceRoot = CoreUtil.getWorkspaceRoot();
File root = workspaceRoot.getLocation().toFile();
AbstractProjectScanner<MavenProjectInfo> scanner = new LocalProjectScanner(root, location, false, mavenModelManager);
scanner.run(monitor);
List<MavenProjectInfo> projects = scanner.getProjects();
List<MavenProjectInfo> mavenProjects = new ArrayList<>();
_findChildMavenProjects(mavenProjects, projects);
mavenProjects = _filterProjects(mavenProjects);
ProjectImportConfiguration importConfiguration = new ProjectImportConfiguration();
IProjectConfigurationManager projectConfigurationManager = MavenPlugin.getProjectConfigurationManager();
return projectConfigurationManager.importProjects(mavenProjects, importConfiguration, monitor);
}
use of org.eclipse.m2e.core.project.MavenProjectInfo in project jbosstools-openshift by jbosstools.
the class MavenProjectImportOperation method getMavenProjects.
private Set<MavenProjectInfo> getMavenProjects(File directory, Collection<String> filters, MavenModelManager modelManager, IProgressMonitor monitor) throws InterruptedException {
if (filters == null || filters.isEmpty()) {
return scan(directory, modelManager, monitor);
}
Set<MavenProjectInfo> projectInfos = new LinkedHashSet<>();
for (String path : filters) {
File dir = new File(directory, path);
projectInfos.addAll(scan(dir, modelManager, monitor));
}
return projectInfos;
}
use of org.eclipse.m2e.core.project.MavenProjectInfo in project jbosstools-openshift by jbosstools.
the class MavenProjectImportOperation method importToWorkspace.
public List<IProject> importToWorkspace(IProgressMonitor monitor) throws CoreException, InterruptedException {
MavenPluginActivator mavenPlugin = MavenPluginActivator.getDefault();
IProjectConfigurationManager configurationManager = mavenPlugin.getProjectConfigurationManager();
MavenModelManager modelManager = mavenPlugin.getMavenModelManager();
Set<MavenProjectInfo> projectInfos = getMavenProjects(getProjectDirectory(), filters, modelManager, monitor);
ProjectImportConfiguration projectImportConfiguration = new ProjectImportConfiguration();
if (overwriteMavenProjects(projectInfos, projectImportConfiguration, monitor)) {
List<IMavenProjectImportResult> importResults = configurationManager.importProjects(projectInfos, projectImportConfiguration, monitor);
return validate(toProjects(importResults));
} else {
return Collections.emptyList();
}
}
use of org.eclipse.m2e.core.project.MavenProjectInfo in project liferay-ide by liferay.
the class MavenUtil method _findChildMavenProjects.
private static void _findChildMavenProjects(List<MavenProjectInfo> results, Collection<MavenProjectInfo> infos) {
for (MavenProjectInfo info : infos) {
results.add(info);
Collection<MavenProjectInfo> children = info.getProjects();
if (ListUtil.isNotEmpty(children)) {
_findChildMavenProjects(results, children);
}
}
}
Aggregations