Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-11-07 12:47:05 -0500
committerIgor Fedorenko2011-11-07 12:47:16 -0500
commite27ce7897641681fabf6eebeacdb90a7e9014277 (patch)
tree8ab1b26e5a1bfeb6af38227da0886016d978fc5f
parent2b455560c1f17e9e5937db18efb24023fee4e506 (diff)
downloadm2e-core-e27ce7897641681fabf6eebeacdb90a7e9014277.tar.gz
m2e-core-e27ce7897641681fabf6eebeacdb90a7e9014277.tar.xz
m2e-core-e27ce7897641681fabf6eebeacdb90a7e9014277.zip
358620 automaticaly reload changed user settings file
Changed user settings.xml file will be automatically taken into account when reading workspace projects. Such implicit settings cache update is not broadcast to ISettingsChangeListener and therefore explicit reload is required for the changed settings to become visible to other parts of m2e, repository view in particular. Signee-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java31
1 files changed, 27 insertions, 4 deletions
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 329ae0c9..f71955fd 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
@@ -186,6 +186,12 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
*/
private Settings settings;
+ /** File length of cached user settings */
+ private long settings_length;
+
+ /** Last modified timestamp of cached user settings */
+ private long settings_timestamp;
+
public MavenImpl(IMavenConfiguration mavenConfiguration) {
this.mavenConfiguration = mavenConfiguration;
mavenConfiguration.addConfigurationChangeListener(this);
@@ -400,18 +406,30 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
return getSettings(false);
}
- public synchronized Settings getSettings(boolean reload) throws CoreException {
+ public synchronized Settings getSettings(final boolean force_reload) throws CoreException {
// MUST NOT use createRequest!
- if (reload || settings==null) {
+ File userSettingsFile = null;
+ if(mavenConfiguration.getUserSettingsFile() != null) {
+ userSettingsFile = new File(mavenConfiguration.getUserSettingsFile());
+ }
+
+ boolean reload = force_reload || settings == null;
+
+ if(!reload && userSettingsFile != null) {
+ reload = userSettingsFile.lastModified() != settings_timestamp
+ || userSettingsFile.length() != settings_length;
+ }
+
+ if(reload) {
// TODO: Can't that delegate to buildSettings()?
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setSystemProperties(System.getProperties());
if(mavenConfiguration.getGlobalSettingsFile() != null) {
request.setGlobalSettingsFile(new File(mavenConfiguration.getGlobalSettingsFile()));
}
- if(mavenConfiguration.getUserSettingsFile() != null) {
- request.setUserSettingsFile(new File(mavenConfiguration.getUserSettingsFile()));
+ if(userSettingsFile != null) {
+ request.setUserSettingsFile(userSettingsFile);
}
try {
settings = lookup(SettingsBuilder.class).build(request).getEffectiveSettings();
@@ -424,6 +442,11 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
*/
settings = new Settings();
}
+
+ if(userSettingsFile != null) {
+ settings_length = userSettingsFile.length();
+ settings_timestamp = userSettingsFile.lastModified();
+ }
}
return settings;
}

Back to the top