Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2013-01-26 20:04:43 -0500
committerIgor Fedorenko2013-02-15 08:40:00 -0500
commit293a1c09ed3ec5401093b7b3b783ea161838b6f0 (patch)
treeb8ac1c5ff9aa49131b824f0f2370865e1a3df627 /org.eclipse.m2e.discovery
parentba5166dd3babd6668b7195c7d8e9302757aecf30 (diff)
downloadm2e-core-293a1c09ed3ec5401093b7b3b783ea161838b6f0.tar.gz
m2e-core-293a1c09ed3ec5401093b7b3b783ea161838b6f0.tar.xz
m2e-core-293a1c09ed3ec5401093b7b3b783ea161838b6f0.zip
397251,356645 introduced MavenExecutionContext
ThreadLocal is used to associate maven execution context with the current thread. The context encapsulates maven session configuration, i.e. force update, offline, etc flags, as well as repository session cache and data. This ensures consistent use of this configuration and data structures by all maven calls performed by the thread. Specicially, * solves multiple cases where forceUpdate was not honoured during project configuration update (bug 397251) * solves extremely slow performance when multiple projects reference the same missing dependency and forceUpdates=true (bug 356645) See IMavenExecutionContext javadoc for new API details Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.discovery')
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java36
1 files changed, 23 insertions, 13 deletions
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java
index 88406358..027ec208 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java
@@ -14,6 +14,7 @@ package org.eclipse.m2e.internal.discovery;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -47,12 +48,12 @@ import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.statushandlers.StatusManager;
-import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.embedder.IMaven;
+import org.eclipse.m2e.core.embedder.ICallable;
+import org.eclipse.m2e.core.embedder.IMavenExecutionContext;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingResult;
import org.eclipse.m2e.core.internal.lifecyclemapping.MappingMetadataSource;
@@ -119,10 +120,9 @@ public class MavenDiscoveryService implements IMavenDiscoveryUI, IMavenDiscovery
public MavenDiscoveryService(boolean factory) {
}
- public Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> discover(MavenProject mavenProject,
- List<MojoExecution> mojoExecutions, List<IMavenDiscoveryProposal> preselected, IProgressMonitor monitor)
- throws CoreException {
- Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> proposals = new LinkedHashMap<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>>();
+ public Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> discover(final MavenProject mavenProject,
+ final List<MojoExecution> mojoExecutions, final List<IMavenDiscoveryProposal> preselected,
+ final IProgressMonitor monitor) throws CoreException {
if(items == null) {
items = new ArrayList<MavenDiscoveryService.CatalogItemCacheEntry>();
@@ -132,7 +132,7 @@ public class MavenDiscoveryService implements IMavenDiscoveryUI, IMavenDiscovery
if(!status.isOK()) {
log.error(status.toString());
- return proposals;
+ return Collections.emptyMap();
}
IProvisioningAgent p2agent = ProvisioningUI.getDefaultUI().getSession().getProvisioningAgent();
@@ -151,9 +151,19 @@ public class MavenDiscoveryService implements IMavenDiscoveryUI, IMavenDiscovery
catalog.dispose();
}
- IMaven maven = MavenPlugin.getMaven();
+ return MavenPlugin.getMaven().execute(
+ new ICallable<Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>>>() {
+ public Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> call(IMavenExecutionContext context, IProgressMonitor monitor)
+ throws CoreException {
+ return discover0(mavenProject, mojoExecutions, preselected, monitor);
+ }
+ }, monitor);
+ }
- MavenExecutionRequest request = maven.createExecutionRequest(monitor); // TODO this ignores workspace dependencies
+ /*package*/Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> discover0(MavenProject mavenProject,
+ List<MojoExecution> mojoExecutions, List<IMavenDiscoveryProposal> preselected, IProgressMonitor monitor)
+ throws CoreException {
+ Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> proposals = new LinkedHashMap<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>>();
Collection<CatalogItem> selectedItems = toCatalogItems(preselected);
List<LifecycleMappingMetadataSource> selectedSources = toMetadataSources(preselected);
@@ -183,11 +193,11 @@ public class MavenDiscoveryService implements IMavenDiscoveryUI, IMavenDiscovery
sources.add(src);
}
- List<MappingMetadataSource> metadataSources = LifecycleMappingFactory.getProjectMetadataSources(request,
- mavenProject, sources, mojoExecutions, false, monitor);
+ List<MappingMetadataSource> metadataSources = LifecycleMappingFactory.getProjectMetadataSources(mavenProject,
+ sources, mojoExecutions, false, monitor);
- LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(mappingResult, request, metadataSources,
- mavenProject, mojoExecutions, false);
+ LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(mappingResult, metadataSources,
+ mavenProject, mojoExecutions, false, monitor);
LifecycleMappingMetadata lifecycleMappingMetadata = mappingResult.getLifecycleMappingMetadata();
if(lifecycleMappingMetadata != null) {

Back to the top