Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-04-20 03:18:12 +0000
committerIgor Fedorenko2011-04-20 03:21:13 +0000
commit4da937a458053d1302b613559bde6ec59b97552c (patch)
tree73fa8fe96b460c950e4dcad070aa22692d3f68cd /org.eclipse.m2e.core
parentc0c5ddb0a296fafdededd4756289fc84824d65cf (diff)
downloadm2e-core-4da937a458053d1302b613559bde6ec59b97552c.tar.gz
m2e-core-4da937a458053d1302b613559bde6ec59b97552c.tar.xz
m2e-core-4da937a458053d1302b613559bde6ec59b97552c.zip
Reconciled dependency update and configuration update actions
Introduced MavenProjectActionSupport to handle project selection during depenency and configuration update consistently. Introduced IProjectConfigurationManager.updateProjectConfiguration(MavenUpdateRequest, IProgressMonitor) Some cleanup of updateProjectConfiguration implementation. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.core')
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java31
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java3
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ProjectConfigurationRequest.java20
3 files changed, 27 insertions, 27 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 71c2f3ac..56f81cca 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
@@ -15,6 +15,7 @@ import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
@@ -45,6 +46,7 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
@@ -240,7 +242,7 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
progress.subTask(NLS.bind(Messages.ProjectConfigurationManager_task_updating, facade.getProject().getName()));
MavenProject mavenProject = facade.getMavenProject(subProgress.newChild(5));
MavenSession mavenSession = createMavenSession(facade, subProgress.newChild(5));
- ProjectConfigurationRequest request = new ProjectConfigurationRequest(facade, mavenProject, mavenSession, false /*updateSources*/);
+ ProjectConfigurationRequest request = new ProjectConfigurationRequest(facade, mavenProject, mavenSession);
updateProjectConfiguration(request, subProgress.newChild(90));
}
}
@@ -269,15 +271,22 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
}
public void updateProjectConfiguration(IProject project, IProgressMonitor monitor) throws CoreException {
- IFile pom = project.getFile(IMavenConstants.POM_FILE_NAME);
- if (pom.isAccessible()) {
- projectManager.refresh(new MavenUpdateRequest(project, mavenConfiguration.isOffline(), false), monitor);
- IMavenProjectFacade facade = projectManager.create(pom, false, monitor);
- if (facade != null) { // facade is null if pom.xml cannot be read
- ProjectConfigurationRequest request = new ProjectConfigurationRequest(facade, facade.getMavenProject(monitor),
- createMavenSession(facade, monitor), true /*updateSources*/);
- updateProjectConfiguration(request, monitor);
- }
+ updateProjectConfiguration(new MavenUpdateRequest(project, mavenConfiguration.isOffline(), false), monitor);
+ }
+
+ public void updateProjectConfiguration(MavenUpdateRequest request, IProgressMonitor monitor) throws CoreException {
+ // for now, only allow one project per request.
+
+ if(request.getPomFiles().size() != 1) {
+ throw new IllegalArgumentException();
+ }
+
+ projectManager.refresh(request, monitor);
+ IMavenProjectFacade facade = projectManager.create(request.getPomFiles().iterator().next(), false, monitor);
+ if(facade != null) { // facade is null if pom.xml cannot be read
+ ProjectConfigurationRequest cfgRequest = new ProjectConfigurationRequest(facade, facade.getMavenProject(monitor),
+ createMavenSession(facade, monitor));
+ updateProjectConfiguration(cfgRequest, monitor);
}
}
@@ -344,7 +353,7 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
ILifecycleMapping lifecycleMapping = getLifecycleMapping(facade);
if(lifecycleMapping != null) {
ProjectConfigurationRequest request = new ProjectConfigurationRequest(facade, facade.getMavenProject(monitor),
- createMavenSession(facade, monitor), false /*updateSources*/);
+ createMavenSession(facade, monitor));
lifecycleMapping.unconfigure(request, monitor);
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java
index 3243293a..87bccea8 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IProjectConfigurationManager.java
@@ -53,6 +53,9 @@ public interface IProjectConfigurationManager {
void updateProjectConfiguration(IProject project, IProgressMonitor monitor)
throws CoreException;
+ void updateProjectConfiguration(MavenUpdateRequest request, IProgressMonitor monitor)
+ throws CoreException;
+
ILifecycleMapping getLifecycleMapping(IMavenProjectFacade projectFacade)
throws CoreException;
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ProjectConfigurationRequest.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ProjectConfigurationRequest.java
index f6f08f49..d5ac8c1a 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ProjectConfigurationRequest.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ProjectConfigurationRequest.java
@@ -20,21 +20,17 @@ import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.ResolverConfiguration;
-/**
- * ProjectConfigurationRequest
- *
- * @author igor
- */
+
public class ProjectConfigurationRequest {
- private final boolean updateSources;
private final IMavenProjectFacade facade;
+
private final MavenProject mavenProject;
+
private final MavenSession mavenSession;
- public ProjectConfigurationRequest(IMavenProjectFacade facade, MavenProject mavenProject, MavenSession mavenSession, boolean updateSources) {
+ public ProjectConfigurationRequest(IMavenProjectFacade facade, MavenProject mavenProject, MavenSession mavenSession) {
this.facade = facade;
this.mavenSession = mavenSession;
- this.updateSources = updateSources;
this.mavenProject = mavenProject;
}
@@ -46,14 +42,6 @@ public class ProjectConfigurationRequest {
return facade.getResolverConfiguration();
}
- public boolean isProjectConfigure() {
- return updateSources;
- }
-
- public boolean isProjectImport() {
- return !updateSources;
- }
-
public MavenProject getMavenProject() {
return mavenProject;
}

Back to the top