Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2013-02-19 18:22:23 -0500
committerIgor Fedorenko2013-02-20 07:27:43 -0500
commitbe7c29dfb8239a08acd6a719841569858db3f2f3 (patch)
tree1023bccd96019f910c4d816a2f895d83c9dd1ac7
parent05acb2b44576d73ed007adc3e81817baac224a8d (diff)
downloadm2e-core-be7c29dfb8239a08acd6a719841569858db3f2f3.tar.gz
m2e-core-be7c29dfb8239a08acd6a719841569858db3f2f3.tar.xz
m2e-core-be7c29dfb8239a08acd6a719841569858db3f2f3.zip
introduced an option to refresh from local during config update
... the option is on by default, but the user can disable it from the project update dialog. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java9
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateMavenProjectAction.java2
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java16
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties37
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java39
6 files changed, 67 insertions, 38 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
index 7f72ea38..48824ed9 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/Messages.java
@@ -881,6 +881,8 @@ public class Messages extends NLS {
public static String BuildDebugView_errorDescription;
+ public static String UpdateMavenProjectsDialog_btnRefreshFromLocal_text;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java
index 1cbd50d9..825cdf9f 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/UpdateMavenProjectJob.java
@@ -45,13 +45,15 @@ public class UpdateMavenProjectJob extends WorkspaceJob {
private final boolean cleanProjects;
+ private final boolean refreshFromLocal;
+
public UpdateMavenProjectJob(IProject[] projects) {
this(projects, MavenPlugin.getMavenConfiguration().isOffline(), false /*forceUpdateDependencies*/,
- true /*updateConfiguration*/, true /*rebuild*/);
+ true /*updateConfiguration*/, true /*rebuild*/, true /*refreshFromLocal*/);
}
public UpdateMavenProjectJob(IProject[] projects, boolean offline, boolean forceUpdateDependencies,
- boolean updateConfiguration, boolean cleanProjects) {
+ boolean updateConfiguration, boolean cleanProjects, boolean refreshFromLocal) {
super(Messages.UpdateSourcesAction_job_update_conf);
@@ -60,6 +62,7 @@ public class UpdateMavenProjectJob extends WorkspaceJob {
this.forceUpdateDependencies = forceUpdateDependencies;
this.updateConfiguration = updateConfiguration;
this.cleanProjects = cleanProjects;
+ this.refreshFromLocal = refreshFromLocal;
setRule(MavenPlugin.getProjectConfigurationManager().getRule());
}
@@ -72,7 +75,7 @@ public class UpdateMavenProjectJob extends WorkspaceJob {
MavenUpdateRequest request = new MavenUpdateRequest(projects, offline, forceUpdateDependencies);
Map<String, IStatus> updateStatus = configurationManager.updateProjectConfiguration(request, updateConfiguration,
- cleanProjects, monitor);
+ cleanProjects, refreshFromLocal, monitor);
Map<String, Throwable> errorMap = new LinkedHashMap<String, Throwable>();
ArrayList<IStatus> errors = new ArrayList<IStatus>();
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateMavenProjectAction.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateMavenProjectAction.java
index 5e019bea..ae1d8e97 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateMavenProjectAction.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateMavenProjectAction.java
@@ -29,7 +29,7 @@ public class UpdateMavenProjectAction extends MavenProjectActionSupport {
UpdateMavenProjectsDialog dialog = new UpdateMavenProjectsDialog(getShell(), getProjects());
if(dialog.open() == Window.OK) {
new UpdateMavenProjectJob(dialog.getSelectedProjects(), dialog.isOffline(), dialog.isForceUpdateDependencies(),
- dialog.isUpdateConfiguration(), dialog.isCleanProjects()).schedule();
+ dialog.isUpdateConfiguration(), dialog.isCleanProjects(), dialog.isRefreshFromLocal()).schedule();
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java
index 033dff32..a6bbf8d6 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java
@@ -102,6 +102,11 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
*/
private boolean cleanProjects;
+ /**
+ * Perform refresh from local before doing anything else.
+ */
+ private boolean refreshFromLocal;
+
protected String dialogTitle;
protected String dialogMessage;
@@ -333,6 +338,10 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
btnUpdateProjectConfiguration.setSelection(true);
btnUpdateProjectConfiguration.setText(Messages.UpdateMavenProjectDialog_btnUpdateProjectConfiguration_text);
+ btnRefreshFromLocal = new Button(optionsComposite, SWT.CHECK);
+ btnRefreshFromLocal.setSelection(true);
+ btnRefreshFromLocal.setText(Messages.UpdateMavenProjectsDialog_btnRefreshFromLocal_text);
+
btnCleanProjects = new Button(optionsComposite, SWT.CHECK);
btnCleanProjects.setSelection(true);
btnCleanProjects.setText(Messages.UpdateMavenProjectDialog_btnCleanProjects_text);
@@ -366,6 +375,7 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
forceUpdateDependencies = forceUpdateBtn.getSelection();
updateConfiguration = btnUpdateProjectConfiguration.getSelection();
cleanProjects = btnCleanProjects.getSelection();
+ refreshFromLocal = btnRefreshFromLocal.getSelection();
super.okPressed();
}
@@ -435,6 +445,10 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
return cleanProjects;
}
+ public boolean isRefreshFromLocal() {
+ return refreshFromLocal;
+ }
+
private IProject getProject(String path) {
return projectPaths.get(path);
}
@@ -485,6 +499,8 @@ public class UpdateMavenProjectsDialog extends TitleAreaDialog implements IMenuL
private Button btnCleanProjects;
+ private Button btnRefreshFromLocal;
+
/**
* @return Returns the dialogTitle or an empty String if the value is null.
*/
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
index c01d6abf..592d779f 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/messages.properties
@@ -1,16 +1,5 @@
-#
-# Copyright (c) 2007, 2008 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
-# Rob Newton - added warning preferences page for disabling warnings
-
#Eclipse modern messages class
-#Mon Dec 24 10:10:21 EST 2012
+#Mon Feb 18 09:07:54 EST 2013
AddDependencyAction_error_msg=Can't add dependency to {0}
AddDependencyAction_error_title=Add Dependency
AddDependencyAction_searchDialog_title=Add Dependency
@@ -19,6 +8,15 @@ AddDependencyDialog_groupId_label=Group Id\:
AddDependencyDialog_scope_label=Scope\:
AddDependencyDialog_version_label=Version\:
AddPluginAction_searchDialog_title=Add Plugin
+BuildDebugView_actionClear=Clear
+BuildDebugView_actionCollapseAll=Collapse All
+BuildDebugView_actionSuspend=Suspend
+BuildDebugView_columnBuildNumber=Build\#
+BuildDebugView_columnName=Name
+BuildDebugView_errorDescription=Could not collection build log
+BuildDebugView_errorTitle=Build debug error
+BuildDebugView_nodeDelta=delta
+BuildDebugView_nodeExecutions=executions
ChangeNatureAction_job_changing=Changing nature
ChangeNatureAction_status_error=Can't change nature
CustomArchetypeDialog_error_artid=Archetype Artifact Id is required
@@ -113,8 +111,8 @@ MavenGoalSelectionDialog_btnQualified=Use &Qualified Name
MavenGoalSelectionDialog_error=Should select at least one goal
MavenGoalSelectionDialog_lblSelect=&Select Goal\:
MavenGoalSelectionDialog_message=Select goal\:
-MavenImportWizardPage_btnSelectTree_text=Select Tree
MavenImportWizardPage_btnDeselectTree_text=Deselect Tree
+MavenImportWizardPage_btnSelectTree_text=Select Tree
MavenImportWizardPage_desc=Select Maven projects
MavenImportWizardPage_inherited=[inherited]
MavenImportWizardPage_mntmDeselectTree_text=Deselect Tree
@@ -330,6 +328,7 @@ UpdateMavenProjectDialog_btnCleanProjects_text=Clean projects
UpdateMavenProjectDialog_btnUpdateProjectConfiguration_text=Update project configuration from pom.xml
UpdateMavenProjectDialog_dialogMessage=Select Maven projects and update options
UpdateMavenProjectDialog_title=Update Maven Project
+UpdateMavenProjectsDialog_btnRefreshFromLocal_text=Refresh workspace resources from local filesystem
UpdateSourcesAction_error_cannot_update=Unable to update Maven configuration
UpdateSourcesAction_error_message=Unable to update maven configuration for the following projects\:
UpdateSourcesAction_error_title=Error Updating Maven Configuration
@@ -431,15 +430,3 @@ wizardProjectPageProjectTitle=New Maven project
wizardProjectPageProjectValidatorInvalidLocation=Invalid project location path
wizardProjectPageProjectValidatorProjectLocation=Enter a location for the project.
wizardProjectTitle=New Maven Project
-BuildDebugView_columnName=Name
-BuildDebugView_columnBuildNumber=Build#
-BuildDebugView_nodeExecutions=executions
-BuildDebugView_nodeDelta=delta
-BuildDebugView_actionSuspend=Suspend
-BuildDebugView_actionClear=Clear
-BuildDebugView_actionCollapseAll=Collapse All
-BuildDebugView_errorTitle=Build debug error
-BuildDebugView_errorDescription=Could not collection build log
-
-
-
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 ed9681c1..2ee5e1ff 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
@@ -288,17 +288,33 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
}
/**
- * Returns project name to update status map
+ * Returns project name to update status map.
+ * <p/>
+ * TODO promote to API
*
- * @since 1.1 TODO promote to API
+ * @since 1.1
*/
public Map<String, IStatus> updateProjectConfiguration(final MavenUpdateRequest request,
final boolean updateConfiguration, final boolean cleanProjects, final IProgressMonitor monitor) {
+ return updateProjectConfiguration(request, updateConfiguration, cleanProjects, false/*refreshFromLocal*/, monitor);
+ }
+
+ /**
+ * Returns project name to update status map.
+ * <p/>
+ * TODO promote to API. TODO decide if workspace or other lock is required during execution of this method.
+ *
+ * @since 1.4
+ */
+ public Map<String, IStatus> updateProjectConfiguration(final MavenUpdateRequest request,
+ final boolean updateConfiguration, final boolean cleanProjects, final boolean refreshFromLocal,
+ final IProgressMonitor monitor) {
try {
return maven.execute(request.isOffline(), request.isForceDependencyUpdate(),
new ICallable<Map<String, IStatus>>() {
public Map<String, IStatus> call(IMavenExecutionContext context, IProgressMonitor monitor) {
- return updateProjectConfiguration0(request.getPomFiles(), updateConfiguration, cleanProjects, monitor);
+ return updateProjectConfiguration0(request.getPomFiles(), updateConfiguration, cleanProjects,
+ refreshFromLocal, monitor);
}
}, monitor);
} catch(CoreException ex) {
@@ -311,10 +327,10 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
}
/*package*/Map<String, IStatus> updateProjectConfiguration0(Collection<IFile> pomFiles, boolean updateConfiguration,
- boolean cleanProjects, IProgressMonitor monitor) {
+ boolean cleanProjects, boolean refreshFromLocal, IProgressMonitor monitor) {
monitor.beginTask(Messages.ProjectConfigurationManager_task_updating_projects, pomFiles.size()
- * (1 + (updateConfiguration ? 1 : 0) + (cleanProjects ? 1 : 0)));
+ * (1 + (updateConfiguration ? 1 : 0) + (cleanProjects ? 1 : 0) + (refreshFromLocal ? 1 : 0)));
long l1 = System.currentTimeMillis();
log.info("Update started"); //$NON-NLS-1$
@@ -324,7 +340,7 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
//project names to the errors encountered when updating them
Map<String, IStatus> updateStatus = new HashMap<String, IStatus>();
- // update all dependencies first
+ // 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) {
@@ -337,8 +353,12 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
monitor.subTask(project.getName());
try {
- SubProgressMonitor submonitor = new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
- projectManager.refresh(Collections.singleton(pom), submonitor);
+ if(refreshFromLocal) {
+ project.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 1,
+ SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
+ }
+ projectManager.refresh(Collections.singleton(pom), new SubProgressMonitor(monitor, 1,
+ SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
IMavenProjectFacade facade = projectManager.getProject(project);
if(facade != null) { // facade is null if pom.xml cannot be read
projects.put(pom, facade);
@@ -390,7 +410,8 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
SubProgressMonitor submonitor = new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
try {
// only rebuild projects that were successfully updated
- if(!updateStatus.containsKey(project.getName())) {
+ IStatus status = updateStatus.get(project.getName());
+ if(status == null || status.isOK()) {
project.build(IncrementalProjectBuilder.CLEAN_BUILD, submonitor);
// TODO provide an option to build projects if the workspace is not autobuilding
}

Back to the top