Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Tanasenko2014-06-07 15:39:02 -0400
committerAnton Tanasenko2014-10-06 12:07:45 -0400
commit7bc157889cb8cb4cc6c036a8467c0d7acd8e1241 (patch)
tree0991036ba9390acc8905e5f1b8583ac6c1235b85 /org.eclipse.m2e.core
parente898ee36879abd11d7ac80aeae9abad92590d7e3 (diff)
downloadm2e-core-7bc157889cb8cb4cc6c036a8467c0d7acd8e1241.tar.gz
m2e-core-7bc157889cb8cb4cc6c036a8467c0d7acd8e1241.tar.xz
m2e-core-7bc157889cb8cb4cc6c036a8467c0d7acd8e1241.zip
445675 Honor workspace autobuild for refreshes caused by pom changes
Change-Id: I76787b503b6637a86b9ff3dbd052d2398149e1c1 Signed-off-by: Anton Tanasenko <atg.sleepless@gmail.com>
Diffstat (limited to 'org.eclipse.m2e.core')
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java43
1 files changed, 2 insertions, 41 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java
index bd85432d..4e07e96e 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob.java
@@ -22,10 +22,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
@@ -41,7 +39,6 @@ import org.eclipse.m2e.core.embedder.IMavenExecutionContext;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.internal.Messages;
import org.eclipse.m2e.core.internal.jobs.IBackgroundProcessingQueue;
-import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenUpdateRequest;
@@ -51,9 +48,6 @@ public class ProjectRegistryRefreshJob extends Job implements IResourceChangeLis
private static final long SCHEDULE_DELAY = 1000L;
- private static final int DELTA_FLAGS = IResourceDelta.CONTENT | IResourceDelta.MOVED_FROM | IResourceDelta.MOVED_TO
- | IResourceDelta.COPIED_FROM | IResourceDelta.REPLACED;
-
private final Set<MavenUpdateRequest> queue = new LinkedHashSet<MavenUpdateRequest>();
/*package*/final ProjectRegistryManager manager;
@@ -149,41 +143,23 @@ public class ProjectRegistryRefreshJob extends Job implements IResourceChangeLis
}
} else {
// if (IResourceChangeEvent.POST_CHANGE == type)
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- boolean autobuilding = workspace != null && workspace.isAutoBuilding();
-
// MavenBuilder will synchronously read/refresh workspace Maven project state.
- // To avoid double-work and/or locking between MavenBuilder and background registry refresh job, we skip project
- // refresh when workspace is autobuilding.
// We still refresh opened projects because workspace does not run build after project open event.
IResourceDelta delta = event.getDelta(); // workspace delta
IResourceDelta[] projectDeltas = delta.getAffectedChildren();
- Set<IProject> refreshProjects = new LinkedHashSet<IProject>();
for(int i = 0; i < projectDeltas.length; i++ ) {
IResourceDelta projectDelta = projectDeltas[i];
IProject project = (IProject) projectDelta.getResource();
if(!isMavenProject(project)) {
continue;
}
-
- //Bug 436679: queue update request only for reopened projects. For imported projects, delta.getKind() == IResourceDelta.ADDED
+ //Bug 436679: queue update request only for reopened projects.
+ //Imported projects (delta.getKind() == IResourceDelta.ADDED) will be taken care of by the builder.
if((projectDelta.getKind() == IResourceDelta.CHANGED && (projectDelta.getFlags() & IResourceDelta.OPEN) != 0)) {
queue(new MavenUpdateRequest(project, offline, forceDependencyUpdate));
- } else if(!autobuilding && projectChanged(projectDelta)) {
- IMavenProjectFacade facade = manager.getProject(project);
- if(facade == null || facade.isStale()) {
- // facade is up-to-date for resource change events fired right after project import
- refreshProjects.add(project);
- }
}
}
-
- if(!refreshProjects.isEmpty()) {
- IProject[] projects = refreshProjects.toArray(new IProject[refreshProjects.size()]);
- MavenUpdateRequest updateRequest = new MavenUpdateRequest(projects, offline, forceDependencyUpdate);
- queue(updateRequest);
- }
}
synchronized(queue) {
@@ -193,16 +169,6 @@ public class ProjectRegistryRefreshJob extends Job implements IResourceChangeLis
}
}
- private boolean projectChanged(IResourceDelta projectDelta) {
- for(IPath path : ProjectRegistryManager.METADATA_PATH) {
- IResourceDelta delta = projectDelta.findMember(path);
- if(delta != null && isInterestingDelta(delta)) {
- return true;
- }
- }
- return false;
- }
-
private void queue(MavenUpdateRequest updateRequest) {
synchronized(queue) {
queue.add(updateRequest);
@@ -225,11 +191,6 @@ public class ProjectRegistryRefreshJob extends Job implements IResourceChangeLis
}
}
- protected boolean isInterestingDelta(IResourceDelta delta) {
- return delta.getKind() == IResourceDelta.REMOVED || delta.getKind() == IResourceDelta.ADDED
- || (delta.getKind() == IResourceDelta.CHANGED && ((delta.getFlags() & DELTA_FLAGS) != 0));
- }
-
private boolean isMavenProject(IProject project) {
try {
return project != null && project.isAccessible() && project.hasNature(IMavenConstants.NATURE_ID);

Back to the top