diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java index 62103133ba..af5fa30ea6 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java @@ -32,6 +32,7 @@ import hudson.Extension; import hudson.FilePath; import hudson.Functions; import hudson.Indenter; +import hudson.Plugin; import hudson.Util; import hudson.maven.local_repo.DefaultLocalRepositoryLocator; import hudson.maven.local_repo.LocalRepositoryLocator; @@ -285,36 +286,47 @@ public class MavenModuleSet extends AbstractMavenProject legacySettings = Class.forName("org.jenkinsci.plugins.configfiles.maven.LegacySettingsProvider").asSubclass(SettingsProvider.class); + Class legacySettings = plugin.getWrapper().classLoader.loadClass("org.jenkinsci.plugins.configfiles.maven.MvnSettingsProvider").asSubclass(SettingsProvider.class); SettingsProvider newInstance = legacySettings.newInstance(); - PropertyUtils.setProperty(newInstance, "settingsConfigId", settingConfigId); + PropertyUtils.setProperty(newInstance, "settingsConfigId", this.settingConfigId); this.settings = newInstance; + this.settingConfigId = null; } catch (Exception e) { - // FIXME how should we log this? - System.out.println("Please update the 'config-file-provider' plugin, the current version is not supported anymore! (settingConfigId="+settingConfigId+")"); + // The PluginUpdateMonitor is also informing the admin about the update + System.err.println("ERROR: Please update the 'config-file-provider' plugin, the current version is not supported anymore! (settingConfigId="+settingConfigId+")"); e.printStackTrace(); } } - if (StringUtils.isNotBlank(globalSettingConfigId)) { + if (plugin != null && StringUtils.isNotBlank(this.globalSettingConfigId)) { try { - Class legacySettings = Class.forName("org.jenkinsci.plugins.configfiles.maven.LegacyGlobalSettingsProvider").asSubclass(GlobalSettingsProvider.class); + Class legacySettings = plugin.getWrapper().classLoader.loadClass("org.jenkinsci.plugins.configfiles.maven.MvnGlobalSettingsProvider").asSubclass(GlobalSettingsProvider.class); GlobalSettingsProvider newInstance = legacySettings.newInstance(); - PropertyUtils.setProperty(newInstance, "settingsConfigId", globalSettingConfigId); + PropertyUtils.setProperty(newInstance, "settingsConfigId", this.globalSettingConfigId); this.globalSettings = newInstance; + this.globalSettingConfigId = null; } catch (Exception e) { - // FIXME how should we log this? - System.out.println("Please update the 'config-file-provider' plugin, the current version is not supported anymore! (globalSettingConfigId="+globalSettingConfigId+")"); + // The PluginUpdateMonitor is also informing the admin about the update + System.err.println("ERROR: Please update the 'config-file-provider' plugin, the current version is not supported anymore! (globalSettingConfigId="+globalSettingConfigId+")"); e.printStackTrace(); } } return this; } - + /** * Reporters configured at {@link MavenModuleSet} level. Applies to all {@link MavenModule} builds. */