Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-04-19 23:18:12 -0400
committerIgor Fedorenko2011-04-19 23:21:13 -0400
commit4da937a458053d1302b613559bde6ec59b97552c (patch)
tree73fa8fe96b460c950e4dcad070aa22692d3f68cd
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>
-rw-r--r--org.eclipse.m2e.core.ui/plugin.properties2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateConfigurationJob.java53
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenActionSupport.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenProjectActionSupport.java69
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateConfigurationAction.java72
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateDependenciesAction.java73
-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
10 files changed, 133 insertions, 194 deletions
diff --git a/org.eclipse.m2e.core.ui/plugin.properties b/org.eclipse.m2e.core.ui/plugin.properties
index 7a97328d..d6ba890c 100644
--- a/org.eclipse.m2e.core.ui/plugin.properties
+++ b/org.eclipse.m2e.core.ui/plugin.properties
@@ -26,7 +26,7 @@ m2.popup.project.update-sources.label=Update Source Folders
m2.popup.ModuleProjectWizardAction=New Maven Module Project
m2.popup.AddPluginAction=Add Plugin
m2.popup.AddDependencyAction=Add Dependency
-m2.popup.UpdateConfigurationAction=Update Project Configuration
+m2.popup.UpdateConfigurationAction=Update Project Configuration...
m2.popup.RefreshMavenModelsAction=Update Dependencies...
m2.popup.OpenUrlAction.openCiPage=Open Continuous Integration
m2.popup.OpenUrlAction.openScmPage=Open Source Control
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateConfigurationJob.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateConfigurationJob.java
index a630b598..b62ab048 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateConfigurationJob.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateConfigurationJob.java
@@ -28,12 +28,13 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.progress.IProgressConstants;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.IProjectConfigurationManager;
+import org.eclipse.m2e.core.project.MavenUpdateRequest;
import org.eclipse.m2e.core.ui.internal.actions.OpenMavenConsoleAction;
import org.eclipse.m2e.core.ui.internal.util.M2EUIUtils;
@@ -41,29 +42,28 @@ import org.eclipse.m2e.core.ui.internal.util.M2EUIUtils;
public class UpdateConfigurationJob extends WorkspaceJob {
private static final Logger log = LoggerFactory.getLogger(UpdateConfigurationJob.class);
- private IProject[] projects;
+ private final IProject[] projects;
- private Shell shell;
+ private final boolean offline;
+
+ private final boolean forceUpdate;
public UpdateConfigurationJob(IProject[] projects) {
- this(projects, null);
+ this(projects, MavenPlugin.getMavenConfiguration().isOffline(), false /*forceUpdate*/);
}
- public UpdateConfigurationJob(IProject[] projects, Shell shell) {
- this(shell);
+ public UpdateConfigurationJob(IProject[] projects, boolean offline, boolean forceUpdate) {
+ super(Messages.UpdateSourcesAction_job_update_conf);
this.projects = projects;
- }
+ this.offline = offline;
+ this.forceUpdate = forceUpdate;
- private UpdateConfigurationJob(Shell shell) {
- super(Messages.UpdateSourcesAction_job_update_conf);
- this.shell = shell;
setRule(MavenPlugin.getProjectConfigurationManager().getRule());
}
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.WorkspaceJob#runInWorkspace(org.eclipse.core.runtime.IProgressMonitor)
- */
public IStatus runInWorkspace(IProgressMonitor monitor) {
+ IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
+
setProperty(IProgressConstants.ACTION_PROPERTY, new OpenMavenConsoleAction());
monitor.beginTask(getName(), projects.length);
@@ -82,23 +82,23 @@ public class UpdateConfigurationJob extends WorkspaceJob {
monitor.subTask(project.getName());
IMavenProjectFacade projectFacade = MavenPlugin.getMavenProjectRegistry().create(project, monitor);
if(projectFacade != null) {
- try {
- MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(project, //
- new SubProgressMonitor(monitor, 1));
- } catch(CoreException ex) {
- if(status == null) {
+ try {
+ MavenUpdateRequest request = new MavenUpdateRequest(project, offline, forceUpdate);
+ configurationManager.updateProjectConfiguration(request, new SubProgressMonitor(monitor, 1));
+ } catch(CoreException ex) {
+ if(status == null) {
+ status = new MultiStatus(IMavenConstants.PLUGIN_ID, IStatus.ERROR, //
+ Messages.UpdateSourcesAction_error_cannot_update, null);
+ }
+ status.add(ex.getStatus());
+ updateErrors.put(project.getName(), ex);
+ } catch(IllegalArgumentException e) {
status = new MultiStatus(IMavenConstants.PLUGIN_ID, IStatus.ERROR, //
Messages.UpdateSourcesAction_error_cannot_update, null);
+ updateErrors.put(project.getName(), e);
}
- status.add(ex.getStatus());
- updateErrors.put(project.getName(), ex);
- } catch(IllegalArgumentException e) {
- status = new MultiStatus(IMavenConstants.PLUGIN_ID, IStatus.ERROR, //
- Messages.UpdateSourcesAction_error_cannot_update, null);
- updateErrors.put(project.getName(), e);
}
}
- }
if(updateErrors.size() > 0) {
handleErrors(updateErrors);
}
@@ -112,9 +112,8 @@ public class UpdateConfigurationJob extends WorkspaceJob {
final Display display = Display.getDefault();
if(display != null) {
display.asyncExec(new Runnable() {
-
public void run() {
- M2EUIUtils.showErrorsForProjectsDialog(shell != null ? shell : display.getActiveShell(),
+ M2EUIUtils.showErrorsForProjectsDialog(display.getActiveShell(),
Messages.UpdateSourcesAction_error_title, Messages.UpdateSourcesAction_error_message, updateErrors);
}
});
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java
index 987d8e6f..4b20e856 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/EnableNatureAction.java
@@ -134,7 +134,7 @@ public class EnableNatureAction implements IObjectActionDelegate, IExecutableExt
IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
- configurationManager.enableMavenNature(project, configuration, new NullProgressMonitor());
+ configurationManager.enableMavenNature(project, configuration, monitor);
if(!hasMavenNature) {
configurationManager.updateProjectConfiguration(project, monitor);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenActionSupport.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenActionSupport.java
index 74370bf8..e40392ef 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenActionSupport.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenActionSupport.java
@@ -76,6 +76,8 @@ public abstract class MavenActionSupport implements IObjectActionDelegate {
public void selectionChanged(IAction action, ISelection selection) {
if(selection instanceof IStructuredSelection) {
this.selection = (IStructuredSelection) selection;
+ } else {
+ this.selection = null;
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenProjectActionSupport.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenProjectActionSupport.java
new file mode 100644
index 00000000..dd66576c
--- /dev/null
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/MavenProjectActionSupport.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.ui.internal.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.m2e.core.core.IMavenConstants;
+
+
+public abstract class MavenProjectActionSupport extends MavenActionSupport implements IWorkbenchWindowActionDelegate {
+
+ private static final Logger log = LoggerFactory.getLogger(UpdateDependenciesAction.class);
+
+ protected IProject[] getProjects() {
+ ArrayList<IProject> projectList = new ArrayList<IProject>();
+ if(selection != null) {
+ for(Iterator<?> it = selection.iterator(); it.hasNext();) {
+ Object o = it.next();
+ if(o instanceof IProject) {
+ projectList.add((IProject) o);
+ } else if(o instanceof IWorkingSet) {
+ IWorkingSet workingSet = (IWorkingSet) o;
+ for(IAdaptable adaptable : workingSet.getElements()) {
+ IProject project = (IProject) adaptable.getAdapter(IProject.class);
+ try {
+ if(project != null && project.isAccessible() && project.hasNature(IMavenConstants.NATURE_ID)) {
+ projectList.add(project);
+ }
+ } catch(CoreException ex) {
+ log.error(ex.getMessage(), ex);
+ }
+ }
+ }
+ }
+ }
+ if(projectList.isEmpty()) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ }
+ return projectList.toArray(new IProject[projectList.size()]);
+ }
+
+ public void dispose() {
+ }
+
+ public void init(IWorkbenchWindow window) {
+ }
+
+}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateConfigurationAction.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateConfigurationAction.java
index 04243201..2372d1f3 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateConfigurationAction.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateConfigurationAction.java
@@ -11,85 +11,25 @@
package org.eclipse.m2e.core.ui.internal.actions;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkingSet;
+import org.eclipse.jface.window.Window;
-import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.ui.internal.UpdateConfigurationJob;
+import org.eclipse.m2e.core.ui.internal.dialogs.UpdateDepenciesDialog;
-public class UpdateConfigurationAction implements IObjectActionDelegate {
- private static final Logger log = LoggerFactory.getLogger(UpdateConfigurationAction.class);
+public class UpdateConfigurationAction extends MavenProjectActionSupport {
public static final String ID = "org.eclipse.m2e.updateConfigurationAction"; //$NON-NLS-1$
- private IStructuredSelection selection;
-
public UpdateConfigurationAction() {
}
-
- public UpdateConfigurationAction(Shell shell) {
- }
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- if(selection instanceof IStructuredSelection) {
- this.selection = (IStructuredSelection) selection;
- } else {
- this.selection = null;
- }
- }
public void run(IAction action) {
- final Set<IProject> projects = getProjects();
- new UpdateConfigurationJob(projects.toArray(new IProject[projects.size()])).schedule();
- }
-
- private Set<IProject> getProjects() {
- Set<IProject> projects = new LinkedHashSet<IProject>();
- if(selection != null) {
- for(Iterator<?> it = selection.iterator(); it.hasNext();) {
- Object element = it.next();
- if(element instanceof IProject) {
- projects.add((IProject) element);
- } else if(element instanceof IWorkingSet) {
- IWorkingSet workingSet = (IWorkingSet) element;
- for(IAdaptable adaptable : workingSet.getElements()) {
- IProject project = (IProject) adaptable.getAdapter(IProject.class);
- try {
- if(project != null && project.isAccessible() && project.hasNature(IMavenConstants.NATURE_ID)) {
- projects.add(project);
- }
- } catch(CoreException ex) {
- log.error(ex.getMessage(), ex);
- }
- }
- } else if(element instanceof IAdaptable) {
- IProject project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);
- if(project != null) {
- projects.add(project);
- }
- }
- }
+ UpdateDepenciesDialog dialog = new UpdateDepenciesDialog(getShell(), getProjects());
+ if(dialog.open() == Window.OK) {
+ new UpdateConfigurationJob(dialog.getSelectedProjects(), dialog.isOffline(), dialog.isForceUpdate()).schedule();
}
- return projects;
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateDependenciesAction.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateDependenciesAction.java
index 6a89b50c..f4bb83ca 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateDependenciesAction.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateDependenciesAction.java
@@ -11,51 +11,22 @@
package org.eclipse.m2e.core.ui.internal.actions;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.IWorkingSet;
import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.eclipse.m2e.core.project.MavenUpdateRequest;
import org.eclipse.m2e.core.ui.internal.dialogs.UpdateDepenciesDialog;
-public class UpdateDependenciesAction extends MavenActionSupport implements IWorkbenchWindowActionDelegate,
- IExecutableExtension {
- private static final Logger log = LoggerFactory.getLogger(UpdateDependenciesAction.class);
+public class UpdateDependenciesAction extends MavenProjectActionSupport {
public static final String ID = "org.eclipse.m2e.refreshMavenModelsAction"; //$NON-NLS-1$
- private IStructuredSelection selection;
-
public UpdateDependenciesAction() {
}
- // IExecutableExtension
-
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) {
- }
-
- // IWorkbenchWindowActionDelegate
-
public void run(IAction action) {
UpdateDepenciesDialog dialog = new UpdateDepenciesDialog(getShell(), getProjects());
if(dialog.open() == Window.OK) {
@@ -65,46 +36,4 @@ public class UpdateDependenciesAction extends MavenActionSupport implements IWor
}
}
- public void selectionChanged(IAction action, ISelection selection) {
- if(selection instanceof IStructuredSelection) {
- this.selection = (IStructuredSelection) selection;
- } else {
- this.selection = null;
- }
- }
-
- public void dispose() {
- }
-
- public void init(IWorkbenchWindow window) {
- }
-
- private IProject[] getProjects() {
- ArrayList<IProject> projectList = new ArrayList<IProject>();
- if(selection != null) {
- for(Iterator<?> it = selection.iterator(); it.hasNext();) {
- Object o = it.next();
- if(o instanceof IProject) {
- projectList.add((IProject) o);
- } else if(o instanceof IWorkingSet) {
- IWorkingSet workingSet = (IWorkingSet) o;
- for(IAdaptable adaptable : workingSet.getElements()) {
- IProject project = (IProject) adaptable.getAdapter(IProject.class);
- try {
- if(project != null && project.isAccessible() && project.hasNature(IMavenConstants.NATURE_ID)) {
- projectList.add(project);
- }
- } catch(CoreException ex) {
- log.error(ex.getMessage(), ex);
- }
- }
- }
- }
- }
- if(projectList.isEmpty()) {
- return ResourcesPlugin.getWorkspace().getRoot().getProjects();
- }
- return projectList.toArray(new IProject[projectList.size()]);
- }
-
}
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