use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenProjectManager method internalDelete.
private void internalDelete(MavenProject parentProject, MavenProject removedModule, UpdateState state) {
for (MavenProject project : findModules(removedModule)) {
internalDelete(removedModule, project, state);
}
writeLock.lock();
try {
if (parentProject == null) {
rootProjects.remove(removedModule);
} else {
removeModule(parentProject, removedModule);
}
projectToMavenProjectMap.remove(removedModule.getProject());
clearMavenKeyMap(removedModule);
moduleToParentMap.remove(removedModule);
parentToModulesMap.remove(removedModule);
} finally {
writeLock.unlock();
}
state.remove(removedModule);
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenProjectManager method internalUpdate.
private void internalUpdate(MavenProject mavenProject, MavenProject parentProject, boolean isNew, boolean recursive, UpdateState state, Deque<MavenProject> stack) {
if (stack.contains(mavenProject)) {
//recursion
return;
}
stack.addFirst(mavenProject);
mavenNotifier.setText("Reading pom: " + mavenProject.getPomPath());
List<MavenProject> oldModules = findModules(mavenProject);
Set<MavenProject> oldChilds = new HashSet<>();
if (!isNew) {
oldChilds.addAll(findChildProjects(mavenProject));
}
writeLock.lock();
try {
if (!isNew) {
clearMavenKeyMap(mavenProject);
}
} finally {
writeLock.unlock();
}
MavenProjectModifications modifications = new MavenProjectModifications();
//re read maven project meta info from pom.xml
modifications = modifications.addChanges(mavenProject.read(serverManager));
writeLock.lock();
try {
fillMavenKeyMap(mavenProject);
projectToMavenProjectMap.put(mavenProject.getProject(), mavenProject);
} finally {
writeLock.unlock();
}
if (isNew) {
addToChild(parentProject, mavenProject);
} else {
updateChild(parentProject, mavenProject);
}
// if (hasparent) {
state.addUpdate(mavenProject, modifications);
// }
List<IProject> modules = mavenProject.getModulesProjects();
List<MavenProject> removedModules = oldModules.stream().filter(oldModule -> !modules.contains(oldModule.getProject())).collect(Collectors.toList());
for (MavenProject removedModule : removedModules) {
removeModule(mavenProject, removedModule);
internalDelete(mavenProject, removedModule, state);
oldChilds.removeAll(state.removedProjects);
}
for (IProject module : modules) {
MavenProject project = findMavenProject(module);
boolean isNewProject = project == null;
if (isNewProject) {
project = new MavenProject(module, workspaceProvider.get());
} else {
MavenProject parent = findParentProject(project);
if (parent != null && parent != mavenProject) {
//TODO add log
continue;
}
}
if (isNewProject || recursive) {
internalUpdate(project, mavenProject, isNewProject, recursive, state, stack);
} else {
if (updateChild(mavenProject, project)) {
state.addUpdate(project, new MavenProjectModifications());
}
}
}
oldChilds.addAll(findChildProjects(mavenProject));
for (MavenProject oldModule : oldChilds) {
internalUpdate(oldModule, findParentProject(oldModule), false, false, state, stack);
}
stack.pop();
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenProjectManager method internalAddMavenProject.
private void internalAddMavenProject(IProject project, boolean recursive, UpdateState state, Deque<MavenProject> stack) {
MavenProject mavenProject = new MavenProject(project, workspaceProvider.get());
MavenProject potentialParent = null;
for (MavenProject parent : getAllProjects()) {
if (parent.containsAsModule(project.getFullPath())) {
potentialParent = parent;
break;
}
}
internalUpdate(mavenProject, potentialParent, true, recursive, state, stack);
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenProjectManager method delete.
public void delete(List<IProject> projects) {
if (projects.isEmpty()) {
return;
}
UpdateState state = new UpdateState();
Deque<MavenProject> stack = new LinkedList<>();
Set<MavenProject> childToUpdate = new HashSet<>();
for (IProject project : projects) {
MavenProject mavenProject = findMavenProject(project);
if (mavenProject == null) {
return;
}
childToUpdate.addAll(findChildProjects(mavenProject));
internalDelete(findParentProject(mavenProject), mavenProject, state);
}
childToUpdate.removeAll(state.removedProjects);
for (MavenProject mavenProject : childToUpdate) {
internalUpdate(mavenProject, null, false, false, state, stack);
}
state.fireUpdate();
}
Aggregations