Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2013-04-09 23:00:58 -0400
committerIgor Fedorenko2013-04-09 23:04:06 -0400
commitc4377bd039acb4d96ca93356699a685f91479a27 (patch)
tree0e3ffea4a3ff03dea31fac227514fd25f47b141c
parent2e010624ac0a8ab9d21afaea0e518a3d791f3e15 (diff)
downloadm2e-core-c4377bd039acb4d96ca93356699a685f91479a27.tar.gz
m2e-core-c4377bd039acb4d96ca93356699a685f91479a27.tar.xz
m2e-core-c4377bd039acb4d96ca93356699a685f91479a27.zip
405090 fixed plugin artifact cache does not honour forceUpdate
This seems to be a bug in maven core, where DefaultPluginArtifactsCache and/or DefaultProjectBuildingHelper do not respect session force dependency update flag. For now, made the fix m2e-specific but should probably fix in maven. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/DefaultMavenComponentContributor.java3
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/EclipsePluginArtifactsCache.java53
2 files changed, 56 insertions, 0 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/DefaultMavenComponentContributor.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/DefaultMavenComponentContributor.java
index 36a600f2..7eeaa05a 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/DefaultMavenComponentContributor.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/DefaultMavenComponentContributor.java
@@ -12,6 +12,7 @@
package org.eclipse.m2e.core.internal.embedder;
import org.apache.maven.classrealm.ClassRealmManagerDelegate;
+import org.apache.maven.plugin.PluginArtifactsCache;
import org.apache.maven.plugin.internal.PluginDependenciesResolver;
import org.apache.maven.project.artifact.MavenMetadataCache;
@@ -19,6 +20,7 @@ import org.sonatype.aether.RepositoryListener;
import org.sonatype.plexus.build.incremental.BuildContext;
import org.eclipse.m2e.core.internal.project.EclipseMavenMetadataCache;
+import org.eclipse.m2e.core.internal.project.EclipsePluginArtifactsCache;
import org.eclipse.m2e.core.internal.project.registry.EclipsePluginDependenciesResolver;
@@ -26,6 +28,7 @@ public class DefaultMavenComponentContributor implements IMavenComponentContribu
public void contribute(IMavenComponentBinder binder) {
binder.bind(MavenMetadataCache.class, EclipseMavenMetadataCache.class, null);
+ binder.bind(PluginArtifactsCache.class, EclipsePluginArtifactsCache.class, null);
binder.bind(PluginDependenciesResolver.class, EclipsePluginDependenciesResolver.class, null);
binder.bind(BuildContext.class, EclipseBuildContext.class, null);
binder.bind(ClassRealmManagerDelegate.class, EclipseClassRealmManagerDelegate.class,
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/EclipsePluginArtifactsCache.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/EclipsePluginArtifactsCache.java
new file mode 100644
index 00000000..2612679e
--- /dev/null
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/EclipsePluginArtifactsCache.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Igor Fedorenko
+ * 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:
+ * Igor Fedorenko - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.internal.project;
+
+import javax.inject.Singleton;
+
+import org.apache.maven.plugin.DefaultPluginArtifactsCache;
+import org.apache.maven.plugin.PluginResolutionException;
+
+import org.sonatype.aether.RepositoryCache;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.RepositoryPolicy;
+
+import org.eclipse.m2e.core.internal.embedder.MavenExecutionContext;
+
+
+@Singleton
+public class EclipsePluginArtifactsCache extends DefaultPluginArtifactsCache {
+
+ public CacheRecord get(Key key) throws PluginResolutionException {
+ MavenExecutionContext context = MavenExecutionContext.getThreadContext();
+
+ if(context == null) {
+ return super.get(key);
+ }
+
+ RepositorySystemSession session = context.getRepositorySession();
+ RepositoryCache sessionCache = session.getCache();
+
+ if(!RepositoryPolicy.UPDATE_POLICY_ALWAYS.equals(session.getUpdatePolicy())
+ || sessionCache.get(session, key) != null) {
+ return super.get(key);
+ }
+
+ // only force refresh once per repository session
+ cache.remove(key);
+ sessionCache.put(session, key, Boolean.TRUE);
+ return null;
+ }
+
+ public EclipsePluginArtifactsCache() {
+ super();
+ }
+}

Back to the top