Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2013-04-27 22:48:13 -0400
committerIgor Fedorenko2013-05-04 12:43:23 -0400
commit8f19e57f772ec9d8bd748652127db4cd19b2ea01 (patch)
treedef6d893182d64f3fdc6d23ad8ef47239fa524ae
parentc92859e1225c14b9f94648b3d9c32d7b566d7c78 (diff)
downloadm2e-core-8f19e57f772ec9d8bd748652127db4cd19b2ea01.tar.gz
m2e-core-8f19e57f772ec9d8bd748652127db4cd19b2ea01.tar.xz
m2e-core-8f19e57f772ec9d8bd748652127db4cd19b2ea01.zip
perf: consolidate registry.refresh invocations
ProjectConfigurationManager refreshed facade for each project being updated separately. This resulted in unnecessary reloading of MavenProject instances for common case of multimodule project. The fix is to invoke registry.refresh for collection of all projects being updated. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java45
1 files changed, 30 insertions, 15 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java
index 2ee5e1ff..3d44b409 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java
@@ -340,31 +340,46 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
//project names to the errors encountered when updating them
Map<String, IStatus> updateStatus = new HashMap<String, IStatus>();
- // refresh projects and update all dependencies
- // this will ensure that project registry is up-to-date on GAV of all projects being updated
- // TODO this sends multiple update events, rework using low-level registry update methods
- for(IFile pom : pomFiles) {
- if(monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
-
- IProject project = pom.getProject();
+ List<IFile> pomsToRefresh = new ArrayList<IFile>();
- monitor.subTask(project.getName());
+ // refresh from local filesystem
+ if(refreshFromLocal) {
+ for(IFile pom : pomFiles) {
+ if(monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
- try {
- if(refreshFromLocal) {
+ IProject project = pom.getProject();
+ try {
project.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 1,
SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
+ pomsToRefresh.add(pom);
+ } catch(CoreException ex) {
+ updateStatus.put(project.getName(), ex.getStatus());
}
- projectManager.refresh(Collections.singleton(pom), new SubProgressMonitor(monitor, 1,
- SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
+ }
+ } else {
+ pomsToRefresh.addAll(pomFiles);
+ }
+
+ // refresh projects and update all dependencies
+ // this will ensure that project registry is up-to-date on GAV of all projects being updated
+ // TODO this sends multiple update events, rework using low-level registry update methods
+ try {
+ projectManager.refresh(pomsToRefresh, new SubProgressMonitor(monitor, pomFiles.size()));
+
+ for(IFile pom : pomsToRefresh) {
+ IProject project = pom.getProject();
IMavenProjectFacade facade = projectManager.getProject(project);
if(facade != null) { // facade is null if pom.xml cannot be read
projects.put(pom, facade);
}
updateStatus.put(project.getName(), Status.OK_STATUS);
- } catch(CoreException ex) {
+ }
+ } catch(CoreException ex) {
+ // TODO per-project status
+ for(IFile pom : pomsToRefresh) {
+ IProject project = pom.getProject();
updateStatus.put(project.getName(), ex.getStatus());
}
}

Back to the top