use of org.eclipse.m2e.core.project.IMavenProjectImportResult 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.IMavenProjectImportResult in project m2e-nar by maven-nar.
the class AbstractTestBuild method importProject.
protected List<IProject> importProject(final String path) {
final ArrayList<IMavenProjectImportResult> importResults = new ArrayList<IMavenProjectImportResult>();
Job job = new Job("Importing test project") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
final IProjectConfigurationManager configManager = MavenPlugin.getProjectConfigurationManager();
final MavenModelManager mavenModelManager = MavenPlugin.getMavenModelManager();
final ProjectImportConfiguration configuration = new ProjectImportConfiguration();
final LocalProjectScanner scanner = new LocalProjectScanner(workspace.getRoot().getLocation().toFile(), path, true, mavenModelManager);
scanner.run(monitor);
final List<MavenProjectInfo> projects = getProjects(scanner.getProjects());
workspace.run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
importResults.addAll(configManager.importProjects(projects, configuration, monitor));
}
}, MavenPlugin.getProjectConfigurationManager().getRule(), IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
return e.getStatus();
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
};
job.schedule();
waitForJobs();
List<IProject> createdProjects = new ArrayList<IProject>();
for (IMavenProjectImportResult r : importResults) {
IProject p = r.getProject();
if (p != null && p.exists()) {
createdProjects.add(p);
}
}
assertFalse("Could not create project " + path, createdProjects.isEmpty());
return createdProjects;
}
Aggregations