Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-04-15 18:30:37 -0400
committerIgor Fedorenko2011-04-15 18:35:52 -0400
commit89d9c968706b8d982fbd9b8379fcf3e00993a0f2 (patch)
tree45ad4737fc31f594d11ef5a61cd1ee2f7f7926e4
parent9d1d5dfa5bf140ee229fbcfb67929c78e7d92f01 (diff)
downloadm2e-core-89d9c968706b8d982fbd9b8379fcf3e00993a0f2.tar.gz
m2e-core-89d9c968706b8d982fbd9b8379fcf3e00993a0f2.tar.xz
m2e-core-89d9c968706b8d982fbd9b8379fcf3e00993a0f2.zip
342910 use 'never' global update policy by default
Introduced new "do not update dependency from remote repositories" preference. When checked (the default) m2e will only contact remote repositories to resolve artifacts that are not present in the local repository and will never attempt to re-resolve artifacts that are already present locally. This is expected to guarantee that all workspace project use the same SNAPSHOT dependency version and improve dependency resolution performance in many common cases as well. 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/messages.properties1
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenPreferencePage.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenConfiguration.java13
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenConfigurationChangeEvent.java1
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java13
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenConfigurationImpl.java18
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java3
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceInitializer.java1
9 files changed, 52 insertions, 5 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 f1d34f58..c15badfc 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
@@ -684,6 +684,8 @@ public class Messages extends NLS {
public static String preferencesOffline;
+ public static String preferencesGlobalUpdateNever;
+
public static String preferencesDebugOutput;
public static String preferencesDownloadSources;
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 eed8c7b5..d1dd7590 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
@@ -347,6 +347,7 @@ preferencesDebugOutput=Debu&g Output
preferencesDownloadJavadoc=Download Artifact &JavaDoc
preferencesDownloadSources=Do&wnload Artifact Sources
preferencesOffline=&Offline
+preferencesGlobalUpdateNever=Do not automatically update dependencies\nfrom remote repositories
preferencesReindexButton=Re&index
projectSelectionDialogTitle=Select a Maven project
resolverConfigurationAdvanced=Ad&vanced
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenPreferencePage.java
index ab874662..db48314e 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenPreferencePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/MavenPreferencePage.java
@@ -45,7 +45,10 @@ public class MavenPreferencePage extends FieldEditorPreferencePage implements IW
addField(new BooleanFieldEditor(MavenPreferenceConstants.P_OFFLINE, Messages.preferencesOffline,
getFieldEditorParent()));
-
+
+ addField(new BooleanFieldEditor(MavenPreferenceConstants.P_GLOBAL_UPDATE_NEVER,
+ Messages.preferencesGlobalUpdateNever, getFieldEditorParent()));
+
addField(new BooleanFieldEditor(MavenPreferenceConstants.P_DEBUG_OUTPUT, //
Messages.preferencesDebugOutput,
getFieldEditorParent()));
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenConfiguration.java
index 070752f7..bb7466ca 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenConfiguration.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMavenConfiguration.java
@@ -25,10 +25,18 @@ public interface IMavenConfiguration {
public void addConfigurationChangeListener(IMavenConfigurationChangeListener listener);
- //
+ // remote dependency resolution
public boolean isOffline();
+ /**
+ * One of org.sonatype.aether.repository.RepositoryPolicy.UPDATE constants or null. If not null, the specified update
+ * policy overrides the update policies of the remote repositories being used for resolution.
+ */
+ public String getGlobalUpdatePolicy();
+
+ // maven settings.xml
+
public String getGlobalSettingsFile();
//settable for embedded maven
@@ -48,7 +56,7 @@ public interface IMavenConfiguration {
public boolean isDebugOutput();
- //
+ // startup update behaviour
public boolean isUpdateProjectsOnStartup();
@@ -58,4 +66,5 @@ public interface IMavenConfiguration {
public boolean isHideFoldersOfNestedProjects();
+
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenConfigurationChangeEvent.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenConfigurationChangeEvent.java
index 323a53a5..905980b9 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenConfigurationChangeEvent.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenConfigurationChangeEvent.java
@@ -28,7 +28,6 @@ public class MavenConfigurationChangeEvent implements MavenPreferenceConstants {
public MavenConfigurationChangeEvent(String key, Object newValue, Object oldValue) {
this.key = key;
- // TODO Auto-generated constructor stub
this.newValue = newValue;
this.oldValue = oldValue;
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
index 6807db51..4bc1e5e0 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
@@ -116,6 +116,7 @@ import org.apache.maven.project.ProjectSorter;
import org.apache.maven.properties.internal.EnvironmentUtils;
import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
+import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
import org.apache.maven.settings.Mirror;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server;
@@ -142,6 +143,7 @@ import org.sonatype.aether.resolution.ArtifactResolutionException;
import org.sonatype.aether.resolution.ArtifactResult;
import org.sonatype.aether.transfer.ArtifactNotFoundException;
import org.sonatype.aether.transfer.TransferListener;
+import org.sonatype.aether.util.FilterRepositorySystemSession;
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.ILocalRepositoryListener;
@@ -259,7 +261,16 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
private RepositorySystemSession createRepositorySession(MavenExecutionRequest request) {
try {
- return ((DefaultMaven) lookup(Maven.class)).newRepositorySession(request);
+ RepositorySystemSession session = ((DefaultMaven) lookup(Maven.class)).newRepositorySession(request);
+ final String updatePolicy = mavenConfiguration.getGlobalUpdatePolicy();
+ if (!request.isUpdateSnapshots() && updatePolicy != null) {
+ session = new FilterRepositorySystemSession(session) {
+ public String getUpdatePolicy() {
+ return updatePolicy;
+ }
+ };
+ }
+ return session;
} catch(CoreException ex) {
log.error(ex.getMessage(), ex);
throw new IllegalStateException("Could not look up Maven embedder", ex);
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenConfigurationImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenConfigurationImpl.java
index ecd44305..afd54578 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenConfigurationImpl.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenConfigurationImpl.java
@@ -30,6 +30,8 @@ import org.eclipse.core.runtime.preferences.IPreferenceFilter;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.sonatype.aether.repository.RepositoryPolicy;
+
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.embedder.IMavenConfiguration;
import org.eclipse.m2e.core.embedder.IMavenConfigurationChangeListener;
@@ -175,4 +177,20 @@ public class MavenConfigurationImpl implements IMavenConfiguration, IPreferenceC
}
};
}
+
+ public String getGlobalUpdatePolicy() {
+ boolean never = Boolean.parseBoolean(preferenceStore.get(MavenPreferenceConstants.P_GLOBAL_UPDATE_NEVER, null,
+ preferencesLookup));
+ return never? RepositoryPolicy.UPDATE_POLICY_NEVER: null;
+ }
+
+ public void setGlobalUpdatePolicy(String policy) {
+ if(policy == null) {
+ preferencesLookup[0].putBoolean(MavenPreferenceConstants.P_GLOBAL_UPDATE_NEVER, false);
+ } else if(RepositoryPolicy.UPDATE_POLICY_NEVER.equals(policy)) {
+ preferencesLookup[0].putBoolean(MavenPreferenceConstants.P_GLOBAL_UPDATE_NEVER, true);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java
index 60e2029c..54abe3e4 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceConstants.java
@@ -31,6 +31,9 @@ public interface MavenPreferenceConstants {
/** boolean */
public static final String P_OFFLINE = PREFIX + "offline"; //$NON-NLS-1$
+ /** boolean. if true, use org.sonatype.aether.repository.RepositoryPolicy.UPDATE_POLICY_NEVER as global update policy */
+ public static final String P_GLOBAL_UPDATE_NEVER = PREFIX + "globalUpdatePolicy"; //$NON-NLS-1$
+
/** boolean */
// public static final String P_UPDATE_SNAPSHOTS = PREFIX+"updateSnapshots";
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceInitializer.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceInitializer.java
index 2e1bde89..2ba49f35 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceInitializer.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/preferences/MavenPreferenceInitializer.java
@@ -44,6 +44,7 @@ public class MavenPreferenceInitializer extends AbstractPreferenceInitializer {
store.putBoolean(MavenPreferenceConstants.P_DEBUG_OUTPUT, false);
store.putBoolean(MavenPreferenceConstants.P_OFFLINE, false);
+ store.putBoolean(MavenPreferenceConstants.P_GLOBAL_UPDATE_NEVER, true);
store.putBoolean(MavenPreferenceConstants.P_DOWNLOAD_SOURCES, false);
store.putBoolean(MavenPreferenceConstants.P_DOWNLOAD_JAVADOC, false);

Back to the top