IntelliJ/Java: Duplicate code
Refactored as PluginManager.logPluginWarnings
@@ -1831,15 +1831,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
LOGGER.log(WARNING, "No such plugin {0} to install", requestedPlugin.getKey());
continue;
}
- if (new VersionNumber(toInstall.version).compareTo(requestedPlugin.getValue()) < 0) {
- LOGGER.log(WARNING, "{0} can only be satisfied in @{1}", new Object[] {requestedPlugin, toInstall.version});
- }
- if (toInstall.isForNewerHudson()) {
- LOGGER.log(WARNING, "{0}@{1} was built for a newer Jenkins", new Object[] {toInstall.name, toInstall.version});
- }
- if (toInstall.isForNewerJava()) {
- LOGGER.log(WARNING, "{0}@{1} was built for a newer Java", new Object[] {toInstall.name, toInstall.version});
- }
+ logPluginWarnings(requestedPlugin, toInstall);
jobs.add(toInstall.deploy(true));
} else if (pw.isOlderThan(requestedPlugin.getValue())) { // upgrade
UpdateSite.Plugin toInstall = uc.getPlugin(requestedPlugin.getKey(), requestedPlugin.getValue());
@@ -1851,6 +1843,17 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
LOGGER.log(WARNING, "{0}@{1} is no newer than what we already have", new Object[] {toInstall.name, toInstall.version});
continue;
}
+ logPluginWarnings(requestedPlugin, toInstall);
+ if (!toInstall.isCompatibleWithInstalledVersion()) {
+ LOGGER.log(WARNING, "{0}@{1} is incompatible with the installed @{2}", new Object[] {toInstall.name, toInstall.version, pw.getVersion()});
+ }
+ jobs.add(toInstall.deploy(true)); // dynamicLoad=true => sure to throw RestartRequiredException, but at least message is nicer
+ } // else already good
+ }
+ return jobs;
+ }
+
+ private void logPluginWarnings(Map.Entry<String, VersionNumber> requestedPlugin, UpdateSite.Plugin toInstall) {
if (new VersionNumber(toInstall.version).compareTo(requestedPlugin.getValue()) < 0) {
LOGGER.log(WARNING, "{0} can only be satisfied in @{1}", new Object[] {requestedPlugin, toInstall.version});
}
@@ -1860,13 +1863,6 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
if (toInstall.isForNewerJava()) {
LOGGER.log(WARNING, "{0}@{1} was built for a newer Java", new Object[] {toInstall.name, toInstall.version});
}
- if (!toInstall.isCompatibleWithInstalledVersion()) {
- LOGGER.log(WARNING, "{0}@{1} is incompatible with the installed @{2}", new Object[] {toInstall.name, toInstall.version, pw.getVersion()});
- }
- jobs.add(toInstall.deploy(true)); // dynamicLoad=true => sure to throw RestartRequiredException, but at least message is nicer
- } // else already good
- }
- return jobs;
}
/**
