diff options
4 files changed, 33 insertions, 7 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java b/sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java index 48a82ce051c..e79ec2e8602 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/SonarUpdate.java @@ -30,7 +30,7 @@ public final class SonarUpdate implements Comparable<SonarUpdate> { private Release release; private List<Plugin> compatiblePlugins = new ArrayList<Plugin>(); private List<Plugin> incompatiblePlugins = new ArrayList<Plugin>(); - private List<Plugin> pluginsToUpgrade = new ArrayList<Plugin>(); + private List<Release> pluginsToUpgrade = new ArrayList<Release>(); public SonarUpdate(Release release) { this.release = release; @@ -48,7 +48,7 @@ public final class SonarUpdate implements Comparable<SonarUpdate> { return incompatiblePlugins; } - public List<Plugin> getPluginsToUpgrade() { + public List<Release> getPluginsToUpgrade() { return pluginsToUpgrade; } @@ -72,7 +72,7 @@ public final class SonarUpdate implements Comparable<SonarUpdate> { incompatiblePlugins.add(plugin); } - public void addPluginToUpgrade(Plugin plugin) { + public void addPluginToUpgrade(Release plugin) { pluginsToUpgrade.add(plugin); } diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinder.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinder.java index feb682869dc..c18c94b5a32 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinder.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinder.java @@ -63,7 +63,7 @@ public final class UpdateFinder { public List<PluginUpdate> findAvailablePlugins() { List<PluginUpdate> availables = new ArrayList<PluginUpdate>(); for (Plugin plugin : center.getPlugins()) { - if (!installedPlugins.containsKey(plugin) && !isAlreadyDownloaded(plugin)) { + if ( !installedPlugins.containsKey(plugin) && !isAlreadyDownloaded(plugin)) { Release release = plugin.getLastCompatibleRelease(installedSonarVersion); if (release != null) { availables.add(PluginUpdate.createWithStatus(release, PluginUpdate.Status.COMPATIBLE)); @@ -93,7 +93,7 @@ public final class UpdateFinder { List<PluginUpdate> updates = new ArrayList<PluginUpdate>(); for (Map.Entry<Plugin, Version> entry : installedPlugins.entrySet()) { Plugin plugin = entry.getKey(); - if (!isAlreadyDownloaded(plugin)) { + if ( !isAlreadyDownloaded(plugin)) { Version pluginVersion = entry.getValue(); for (Release release : plugin.getReleasesGreaterThan(pluginVersion)) { updates.add(PluginUpdate.createForPluginRelease(release, installedSonarVersion)); @@ -128,13 +128,15 @@ public final class UpdateFinder { } else { // search for a compatible plugin upgrade boolean ok = false; + Release compatibleRelease = null; for (Release greaterPluginRelease : plugin.getReleasesGreaterThan(pluginVersion)) { if (greaterPluginRelease.supportSonarVersion(sonarRelease.getVersion())) { + compatibleRelease = greaterPluginRelease; ok = true; } } if (ok) { - update.addPluginToUpgrade(plugin); + update.addPluginToUpgrade(compatibleRelease); } else { update.addIncompatiblePlugin(plugin); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb index 5fc452e1171..ec8a5b7efa2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb @@ -17,6 +17,29 @@ not compatible, needs Sonar upgrade <% end %> </td> + <% else %> + <td> + <% if update.hasWarnings() %> + <% if update.isIncompatible() %> + Those plugins not compatible and must be uninstalled before Sonar upgrade: + <ul> + <% update.getIncompatiblePlugins().each do |plugin| %> + <li><%= plugin.getName() -%></li> + <% end %> + </ul> + <% end %> + <% if update.requiresPluginUpgrades() %> + Those plugins must be upgraded: + <ul> + <% update.getPluginsToUpgrade().each do |plugin| %> + <li><%= plugin.getArtifact().getName() -%> to <%= plugin.getVersion() -%></li> + <% end %> + </ul> + <% end %> + <% else %> + All installed plugins are compatible + <% end %> + </td> <% end %> </tr> <% end %> diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/SonarUpdateTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/SonarUpdateTest.java index 17356a7538f..45369fd4816 100644 --- a/sonar-server/src/test/java/org/sonar/server/plugins/SonarUpdateTest.java +++ b/sonar-server/src/test/java/org/sonar/server/plugins/SonarUpdateTest.java @@ -23,6 +23,7 @@ import org.junit.Test; import org.sonar.updatecenter.common.Plugin; import org.sonar.updatecenter.common.Release; import org.sonar.updatecenter.common.Sonar; +import org.sonar.updatecenter.common.Version; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -41,7 +42,7 @@ public class SonarUpdateTest { @Test public void incompatibleUpdateIfRequiredPluginUpgrades() { SonarUpdate update = new SonarUpdate(new Release(new Sonar(), "2.3")); - update.addPluginToUpgrade(new Plugin("old")); + update.addPluginToUpgrade(new Release(new Plugin("old"), Version.create("0.2"))); assertFalse(update.isIncompatible()); assertTrue(update.hasWarnings()); assertTrue(update.requiresPluginUpgrades()); |