use of org.eclipse.m2e.core.project.MavenProjectInfo in project liferay-ide by liferay.
the class MavenUtil method _filterProjects.
private static List<MavenProjectInfo> _filterProjects(List<MavenProjectInfo> mavenProjects) {
List<MavenProjectInfo> result = new ArrayList<>();
for (MavenProjectInfo info : mavenProjects) {
if (info != null) {
File pomFile = info.getPomFile();
URI mavenuri = pomFile.getParentFile().toURI();
if (mavenuri.toString().endsWith("/")) {
try {
mavenuri = new URI(mavenuri.toString().substring(0, mavenuri.toString().length() - 1));
} catch (URISyntaxException urise) {
}
}
boolean alreadyExists = false;
for (IProject project : CoreUtil.getAllProjects()) {
if (FileUtil.exists(project) && project.getLocationURI().equals(mavenuri)) {
alreadyExists = true;
break;
}
}
if (!alreadyExists) {
result.add(info);
}
}
}
return result;
}
use of org.eclipse.m2e.core.project.MavenProjectInfo in project eclipse.jdt.ls by eclipse.
the class MavenProjectImporter method applies.
@Override
public boolean applies(IProgressMonitor monitor) throws OperationCanceledException, CoreException {
PreferenceManager preferencesManager = JavaLanguageServerPlugin.getPreferencesManager();
if (preferencesManager != null && !preferencesManager.getPreferences().isImportMavenEnabled()) {
return false;
}
Set<MavenProjectInfo> files = getMavenProjectInfo(monitor);
if (files != null) {
Iterator<MavenProjectInfo> iter = files.iterator();
while (iter.hasNext()) {
MavenProjectInfo projectInfo = iter.next();
File dir = projectInfo.getPomFile() == null ? null : projectInfo.getPomFile().getParentFile();
if (dir != null && exclude(dir.toPath())) {
iter.remove();
}
}
}
return files != null && !files.isEmpty();
}
use of org.eclipse.m2e.core.project.MavenProjectInfo in project jbosstools-openshift by jbosstools.
the class MavenProjectImportOperation method overwriteMavenProjects.
private boolean overwriteMavenProjects(Collection<MavenProjectInfo> projectInfos, final ProjectImportConfiguration configuration, IProgressMonitor monitor) throws CoreException {
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
Set<IProject> s1 = projectInfos.stream().map(project -> configuration.getProjectName(project.getModel())).map(root::getProject).filter(project -> project.exists()).collect(Collectors.toSet());
boolean overwrite = true;
if (!s1.isEmpty()) {
final String message = (s1.size() == 1) ? NLS.bind(OpenShiftCommonUIMessages.MavenProjectWarningMessage, s1.iterator().next().getName()) : OpenShiftCommonUIMessages.MavenProjectsWarningMessage;
overwrite = displayOverwriteDialog(OpenShiftCommonUIMessages.OverwriteProjectsDialogTitle, message);
for (IProject project : s1) {
if (overwrite) {
project.delete(false, true, monitor);
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
}
}
return overwrite;
}
use of org.eclipse.m2e.core.project.MavenProjectInfo 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;
}
use of org.eclipse.m2e.core.project.MavenProjectInfo in project m2e-nar by maven-nar.
the class AbstractTestBuild method getProjects.
private List<MavenProjectInfo> getProjects(Collection<MavenProjectInfo> input) {
List<MavenProjectInfo> toRet = new ArrayList<MavenProjectInfo>();
for (MavenProjectInfo info : input) {
toRet.add(info);
toRet.addAll(getProjects(info.getProjects()));
}
return toRet;
}
Aggregations