From 908c5ace5d6b883c66e426c08cece44e8f9a166a Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Mon, 17 Jun 2019 19:00:40 +0200 Subject: [PATCH 01/24] Enable labels/categories with `deprecated` to show a warning for plugins --- core/src/main/java/hudson/PluginManager.java | 33 +++++++++++++++++ core/src/main/java/hudson/PluginWrapper.java | 9 +++++ .../main/resources/hudson/Messages.properties | 1 + .../PluginDeprecationMonitor/message.jelly | 35 +++++++++++++++++++ .../message.properties | 24 +++++++++++++ 5 files changed, 102 insertions(+) create mode 100644 core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly create mode 100644 core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 1b73d6679c..c12dcaa63b 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -2235,6 +2235,39 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas } + /** + * {@link AdministrativeMonitor} that checks if there are any plugins with cycle dependencies. + */ + @Extension @Symbol("pluginDeprecation") + public static final class PluginDeprecationMonitor extends AdministrativeMonitor { + + @Override + public String getDisplayName() { + return Messages.PluginManager_PluginDeprecationMonitor_DisplayName(); + } + + private transient volatile boolean isActive = false; + + private transient volatile List deprecatedPlugins; + + public boolean isActivated() { + if(deprecatedPlugins == null){ + deprecatedPlugins = new ArrayList<>(); + for (PluginWrapper p : Jenkins.get().getPluginManager().getPlugins()) { + if(p.isDeprecated()){ + deprecatedPlugins.add(p); + isActive = true; + } + } + } + return isActive; + } + + public List getDeprecatedPlugins() { + return deprecatedPlugins; + } + } + @Override @Restricted(NoExternalUse.class) public Object getTarget() { diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index 715c04db26..81f3ca0eee 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -362,6 +362,15 @@ public class PluginWrapper implements Comparable, ModelObject { return dependencies.stream().anyMatch(d -> !d.optional); } + /** + * Is this plugin labeled deprecated? + * @return {@code true} when plugin contains deprecated in categories, otherwise {@code false}. + */ + public boolean isDeprecated() { + UpdateSite.Plugin info = getInfo(); + return info != null && Arrays.asList(info.categories).contains("deprecated"); + } + @ExportedBean public static final class Dependency { @Exported diff --git a/core/src/main/resources/hudson/Messages.properties b/core/src/main/resources/hudson/Messages.properties index 20f79ad0b0..4cfbc0c31a 100644 --- a/core/src/main/resources/hudson/Messages.properties +++ b/core/src/main/resources/hudson/Messages.properties @@ -63,6 +63,7 @@ PluginManager.ConfigureUpdateCenterPermission.Description=\ configure update sites and proxy settings. PluginManager.PluginCycleDependenciesMonitor.DisplayName=Cyclic Dependencies Detector PluginManager.PluginUpdateMonitor.DisplayName=Invalid Plugin Configuration +PluginManager.PluginDeprecationMonitor.DisplayName=Deprecated Plugin Monitor PluginManager.CheckUpdateServerError=There were errors checking the update sites: {0} PluginManager.UpdateSiteError=Error checking update sites for {0} attempt(s). Last exception was: {1} PluginManager.UpdateSiteChangeLogLevel=Change the log level of {0} logger to WARNING or below to see more information and the error message of every attempt diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly new file mode 100644 index 0000000000..e56a70c212 --- /dev/null +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly @@ -0,0 +1,35 @@ + + + + +
+
+
${%DeprecatedPlugins}
+ +
+
+
+
+
diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties new file mode 100644 index 0000000000..a63fdcdbc1 --- /dev/null +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties @@ -0,0 +1,24 @@ +# The MIT License +# +# Copyright (c) 2019, Joseph Petersen +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + + +DeprecatedPlugins=The following plugins can be uninstalled as they have been marked as deprecated From 7271e484e14d59409915d69417e2b26890405484 Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Mon, 17 Jun 2019 20:18:52 +0200 Subject: [PATCH 02/24] fix doc --- core/src/main/java/hudson/PluginManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index c12dcaa63b..23e472f6a2 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -2236,7 +2236,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas } /** - * {@link AdministrativeMonitor} that checks if there are any plugins with cycle dependencies. + * {@link AdministrativeMonitor} that checks if there are any plugins that is deprecated. */ @Extension @Symbol("pluginDeprecation") public static final class PluginDeprecationMonitor extends AdministrativeMonitor { @@ -2251,10 +2251,10 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas private transient volatile List deprecatedPlugins; public boolean isActivated() { - if(deprecatedPlugins == null){ + if (deprecatedPlugins == null) { deprecatedPlugins = new ArrayList<>(); for (PluginWrapper p : Jenkins.get().getPluginManager().getPlugins()) { - if(p.isDeprecated()){ + if (p.isDeprecated()) { deprecatedPlugins.add(p); isActive = true; } From 42afdd35089f029dcf33af047459bbccb59c84de Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Mon, 17 Jun 2019 22:52:35 +0200 Subject: [PATCH 03/24] Wording Co-Authored-By: Daniel Beck <1831569+daniel-beck@users.noreply.github.com> --- .../PluginManager/PluginDeprecationMonitor/message.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties index a63fdcdbc1..80d3ac66f0 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties @@ -21,4 +21,4 @@ # THE SOFTWARE. -DeprecatedPlugins=The following plugins can be uninstalled as they have been marked as deprecated +DeprecatedPlugins=The following plugins have been marked as deprecated. In general this means that the plugin is obsolete, no longer being developed, or may no longer work. See the plugin's documentation for further information about the cause for the deprecation, and suggestions how to proceed. From aa863548bc5ec71f1220552368db4fa022dc5ed9 Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Sat, 12 Oct 2019 11:13:52 +0200 Subject: [PATCH 04/24] Add Restricted no external use --- core/src/main/java/hudson/PluginManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 23e472f6a2..9094acb7f8 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -2238,7 +2238,9 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas /** * {@link AdministrativeMonitor} that checks if there are any plugins that is deprecated. */ - @Extension @Symbol("pluginDeprecation") + @Restricted(NoExternalUse.class) + @Symbol("pluginDeprecation") + @Extension public static final class PluginDeprecationMonitor extends AdministrativeMonitor { @Override From c1b532b437b33f354804250f3e6bd2bfae2ee30e Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Sat, 12 Oct 2019 11:14:04 +0200 Subject: [PATCH 05/24] add since todo --- core/src/main/java/hudson/PluginWrapper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index 81f3ca0eee..7b27dfd697 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -365,6 +365,7 @@ public class PluginWrapper implements Comparable, ModelObject { /** * Is this plugin labeled deprecated? * @return {@code true} when plugin contains deprecated in categories, otherwise {@code false}. + * @since TODO */ public boolean isDeprecated() { UpdateSite.Plugin info = getInfo(); From 34e1e14c0e0beeb3ab449b7886e61a9a9d30c4fe Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Sat, 12 Oct 2019 11:15:14 +0200 Subject: [PATCH 06/24] spelling Co-Authored-By: Tim Jacomb --- .../PluginManager/PluginDeprecationMonitor/message.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties index 80d3ac66f0..dc802c449b 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties @@ -21,4 +21,4 @@ # THE SOFTWARE. -DeprecatedPlugins=The following plugins have been marked as deprecated. In general this means that the plugin is obsolete, no longer being developed, or may no longer work. See the plugin's documentation for further information about the cause for the deprecation, and suggestions how to proceed. +DeprecatedPlugins=The following plugins have been marked as deprecated. In general this means that the plugin is obsolete, no longer being developed, or may no longer work. See the plugin's documentation for further information about the cause for the deprecation, and suggestions on how to proceed. From d19fdb4c9130051954a8e2e94b7856f27d3d94df Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Wed, 19 Feb 2020 19:25:01 +0100 Subject: [PATCH 07/24] use stream api to collect deprecated plugins --- core/src/main/java/hudson/PluginManager.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index a245f8b131..d4ec6a3dd2 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -2250,13 +2250,10 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas public boolean isActivated() { if (deprecatedPlugins == null) { - deprecatedPlugins = new ArrayList<>(); - for (PluginWrapper p : Jenkins.get().getPluginManager().getPlugins()) { - if (p.isDeprecated()) { - deprecatedPlugins.add(p); - isActive = true; - } - } + deprecatedPlugins = Jenkins.get().getPluginManager().getPlugins().stream() + .filter(PluginWrapper::isDeprecated) + .collect(Collectors.toList()); + isActive = !deprecatedPlugins.isEmpty(); } return isActive; } From 6be9ddf3f970f8c8df8d1e5268656e3a7bf479d6 Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Wed, 19 Feb 2020 19:26:35 +0100 Subject: [PATCH 08/24] link to plugin url --- .../PluginManager/PluginDeprecationMonitor/message.jelly | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly index e56a70c212..b41e38d567 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly @@ -28,7 +28,14 @@ THE SOFTWARE.
${%DeprecatedPlugins}
-
+ + +
${p.longName} ${p.version}
+
+ +
${p.longName} ${p.version}
+
+
From cab322fc2c78a730c4fa6f71ed501b9d34c6c5ee Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Wed, 19 Feb 2020 19:42:00 +0100 Subject: [PATCH 09/24] add break lines to deprecation message --- .../PluginDeprecationMonitor/message.properties | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties index dc802c449b..b514392c12 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties @@ -21,4 +21,7 @@ # THE SOFTWARE. -DeprecatedPlugins=The following plugins have been marked as deprecated. In general this means that the plugin is obsolete, no longer being developed, or may no longer work. See the plugin's documentation for further information about the cause for the deprecation, and suggestions on how to proceed. +DeprecatedPlugins=\ + The following plugins have been marked as deprecated.
\ + In general this means that the plugin is obsolete, no longer being developed, or may no longer work.
\ + See the plugin's documentation for further information about the cause for the deprecation, and suggestions on how to proceed. From 469e117e6386c9d035f5d78761eff377f78b9c4a Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Wed, 19 Feb 2020 19:59:05 +0100 Subject: [PATCH 10/24] fix regex --- .../hudson/PluginManager/PluginDeprecationMonitor/message.jelly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly index b41e38d567..277ede9469 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly @@ -29,7 +29,7 @@ THE SOFTWARE.
${%DeprecatedPlugins}
- +
${p.longName} ${p.version}
From 22f9cc9ab2e2dd45f195a89fd918c920db5565a3 Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Wed, 19 Feb 2020 20:57:00 +0100 Subject: [PATCH 11/24] wording and separation of description --- .../PluginManager/PluginDeprecationMonitor/message.jelly | 1 + .../PluginDeprecationMonitor/message.properties | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly index 277ede9469..fdd14ef538 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly @@ -38,5 +38,6 @@ THE SOFTWARE.
+

${%DeprecatedPluginsDescription}

diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties index b514392c12..837b2baad1 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties @@ -21,7 +21,7 @@ # THE SOFTWARE. -DeprecatedPlugins=\ - The following plugins have been marked as deprecated.
\ - In general this means that the plugin is obsolete, no longer being developed, or may no longer work.
\ +DeprecatedPlugins=There are deprecated plugins installed +DeprecatedPluginsDescription=\ + In general, this means that these plugins are either obsolete, no longer being developed, or may no longer work.
\ See the plugin's documentation for further information about the cause for the deprecation, and suggestions on how to proceed. From a05b37ea87205dd41193acbc2b9e193a8a211b54 Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Wed, 19 Feb 2020 22:36:52 +0100 Subject: [PATCH 12/24] Hide deprecated plugins inside the available section on update center --- core/src/main/java/hudson/PluginWrapper.java | 3 +-- core/src/main/java/hudson/model/UpdateCenter.java | 4 ++++ core/src/main/java/hudson/model/UpdateSite.java | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index 3b537f4a63..5b738e8237 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -369,8 +369,7 @@ public class PluginWrapper implements Comparable, ModelObject { * @since TODO */ public boolean isDeprecated() { - UpdateSite.Plugin info = getInfo(); - return info != null && Arrays.asList(info.categories).contains("deprecated"); + return getInfo().isDeprecated(); } @ExportedBean diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index 4ab5e89cda..d9d81537e3 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -969,6 +969,10 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas Map pluginMap = new LinkedHashMap<>(); for (UpdateSite site : sites) { for (Plugin plugin: site.getAvailables()) { + if (plugin.isDeprecated()) { + // hide plugins that are deprecated + continue; + } final Plugin existing = pluginMap.get(plugin.name); if (existing == null) { pluginMap.put(plugin.name, plugin); diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index de54334b95..225ec7912a 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -44,6 +44,7 @@ import java.net.URI; import java.net.URL; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -1338,6 +1339,15 @@ public class UpdateSite { return warnings; } + /** + * Is this plugin labeled deprecated? + * @return {@code true} when plugin contains deprecated in categories, otherwise {@code false}. + * @since TODO + */ + public boolean isDeprecated() { + return categories != null && Arrays.asList(categories).contains("deprecated"); + } + /** * @since 2.40 */ From 0d52bc12542e9536c2c23f64b494dc2818a86e3d Mon Sep 17 00:00:00 2001 From: Joseph Petersen Date: Wed, 19 Feb 2020 22:59:49 +0100 Subject: [PATCH 13/24] Add a warning inside the installed section on plugin manager --- core/src/main/resources/hudson/PluginManager/installed.jelly | 5 +++++ .../main/resources/hudson/PluginManager/installed.properties | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/core/src/main/resources/hudson/PluginManager/installed.jelly b/core/src/main/resources/hudson/PluginManager/installed.jelly index 4660aa776e..b934172496 100644 --- a/core/src/main/resources/hudson/PluginManager/installed.jelly +++ b/core/src/main/resources/hudson/PluginManager/installed.jelly @@ -102,6 +102,11 @@ THE SOFTWARE. + +
+ ${%deprecationWarning} +
+
diff --git a/core/src/main/resources/hudson/PluginManager/installed.properties b/core/src/main/resources/hudson/PluginManager/installed.properties index fbf32e5c6f..f318690a5c 100644 --- a/core/src/main/resources/hudson/PluginManager/installed.properties +++ b/core/src/main/resources/hudson/PluginManager/installed.properties @@ -24,3 +24,7 @@ requires.restart=This Jenkins instance requires a restart. Changing the state of detached-disable=This plugin may not be safe to disable detached-uninstall=This plugin may not be safe to uninstall detached-possible-dependents=Its functionality was at one point moved out of Jenkins core, and another plugin with a core dependency predating the split may be relying on it implicitly. +deprecationWarning=\ + Warning: This plugin has been marked as deprecated.
\ + In general, this means that this plugin is either obsolete, no longer being developed, or may no longer work.
\ + This plugin may be safe to uninstall From d213ef962cb818a2b244b374cdc518133bbe6d32 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sun, 3 May 2020 18:32:17 +0200 Subject: [PATCH 14/24] Add support for top-level 'deprecations' element in update site --- core/src/main/java/hudson/PluginManager.java | 20 ++--- core/src/main/java/hudson/PluginWrapper.java | 29 ++++++- .../main/java/hudson/model/UpdateCenter.java | 4 - .../main/java/hudson/model/UpdateSite.java | 84 +++++++++++++++++-- .../PluginDeprecationMonitor/message.jelly | 6 +- .../message.properties | 2 +- .../hudson/PluginManager/installed.jelly | 4 +- .../hudson/PluginManager/installed.properties | 5 +- .../hudson/PluginManager/table.jelly | 5 ++ .../hudson/PluginManager/table.properties | 1 + 10 files changed, 121 insertions(+), 39 deletions(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 58a419b568..e0914220d4 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -2239,7 +2239,9 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas } /** - * {@link AdministrativeMonitor} that checks if there are any plugins that is deprecated. + * {@link AdministrativeMonitor} that checks if there are any plugins that are deprecated. + * + * @since TODO */ @Restricted(NoExternalUse.class) @Symbol("pluginDeprecation") @@ -2251,22 +2253,14 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas return Messages.PluginManager_PluginDeprecationMonitor_DisplayName(); } - private transient volatile boolean isActive = false; - - private transient volatile List deprecatedPlugins; - public boolean isActivated() { - if (deprecatedPlugins == null) { - deprecatedPlugins = Jenkins.get().getPluginManager().getPlugins().stream() - .filter(PluginWrapper::isDeprecated) - .collect(Collectors.toList()); - isActive = !deprecatedPlugins.isEmpty(); - } - return isActive; + return !getDeprecatedPlugins().isEmpty(); } public List getDeprecatedPlugins() { - return deprecatedPlugins; + return Jenkins.get().getPluginManager().getPlugins().stream() + .filter(PluginWrapper::isDeprecated) + .collect(Collectors.toList()); } } diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index 4084f43488..32c67e771d 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -365,12 +365,18 @@ public class PluginWrapper implements Comparable, ModelObject { } /** - * Is this plugin labeled deprecated? - * @return {@code true} when plugin contains deprecated in categories, otherwise {@code false}. + * Is this plugin deprecated? + * + * @return {@code true} if and only if an update site reports deprecations for this plugin. * @since TODO */ + @Restricted(NoExternalUse.class) public boolean isDeprecated() { - return getInfo().isDeprecated(); + /* + While better handled in UpdateSite.Plugin that only exists for plugins actively being published. + We have no good model for plugin metadata from update sites for plugins not being published. + */ + return !getDeprecations().isEmpty(); } @ExportedBean @@ -562,8 +568,11 @@ public class PluginWrapper implements Comparable, ModelObject { /** * Returns a one-line descriptive name of this plugin. + * + * @deprecated For most purposes, use {@link #getDisplayName()}. */ @Exported + @Deprecated public String getLongName() { String name = manifest.getMainAttributes().getValue("Long-Name"); if(name!=null) return name; @@ -1293,6 +1302,20 @@ public class PluginWrapper implements Comparable, ModelObject { return ExtensionList.lookupSingleton(UpdateSiteWarningsMonitor.class).getActivePluginWarningsByPlugin().getOrDefault(this, Collections.emptyList()); } + @Restricted(NoExternalUse.class) + public Set getDeprecations() { + /* Would be much nicer to go through getInfoFromAllSites but that only works for currently published plugins */ + Set deprecations = new HashSet<>(); + for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) { + for (Map.Entry entry : site.getData().getDeprecations().entrySet()) { + if (entry.getKey().equals(this.shortName)) { + deprecations.add(entry.getValue()); + } + } + } + return deprecations; + } + private static final Logger LOGGER = Logger.getLogger(PluginWrapper.class.getName()); /** diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index d143a539ba..84994570cb 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -976,10 +976,6 @@ public class UpdateCenter extends AbstractModelObject implements Saveable, OnMas Map pluginMap = new LinkedHashMap<>(); for (UpdateSite site : sites) { for (Plugin plugin: site.getAvailables()) { - if (plugin.isDeprecated()) { - // hide plugins that are deprecated - continue; - } final Plugin existing = pluginMap.get(plugin.name); if (existing == null) { pluginMap.put(plugin.name, plugin); diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 3af8ecd2bc..7f0acaf9e7 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -49,10 +49,13 @@ import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Date; +import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.TreeMap; import java.util.UUID; @@ -556,6 +559,13 @@ public class UpdateSite { */ private final Set warnings = new HashSet<>(); + /** + * Mapping of plugin IDs to deprecation notices + * + * @since TODO + */ + private final Map deprecations = new HashMap<>(); + /** * If this is non-null, Jenkins is going to check the connectivity to this URL to make sure * the network connection is up. Null to skip the check. @@ -582,6 +592,19 @@ public class UpdateSite { } } + JSONObject deprecations = o.optJSONObject("deprecations"); + if (deprecations != null) { + for (Iterator it = deprecations.keys(); it.hasNext(); ) { + try { + String pluginId = it.next().toString(); + String referenceUrl = deprecations.getString(pluginId); + this.deprecations.put(pluginId, new Deprecation(referenceUrl)); + } catch (JSONException ex) { + LOGGER.log(Level.WARNING, "Failed to parse JSON for deprecation", ex); + } + } + } + for(Map.Entry e : (Set>)o.getJSONObject("plugins").entrySet()) { Plugin p = new Plugin(sourceId, e.getValue()); // JENKINS-33308 - include implied dependencies for older plugins that may need them @@ -594,6 +617,14 @@ public class UpdateSite { } } plugins.put(Util.intern(e.getKey()), p); + + // compatibility with update sites that have no separate 'deprecated' top-level entry. + // Also do this even if there are deprecations to potentially allow limiting the top-level entry to overridden URLs. + if (Arrays.asList(p.categories).contains("deprecated")) { + if (!this.deprecations.containsKey(p.name)) { + this.deprecations.put(p.name, new Deprecation(p.wiki)); + } + } } connectionCheckUrl = (String)o.get("connectionCheckUrl"); @@ -609,6 +640,16 @@ public class UpdateSite { return this.warnings; } + /** + * Returns the deprecations provided by the update site + * @return the deprecations provided by the update site + * @since TODO + */ + @Restricted(NoExternalUse.class) + public Map getDeprecations() { + return this.deprecations; + } + /** * Is there a new version of the core? */ @@ -791,6 +832,32 @@ public class UpdateSite { } } + /** + * Represents a deprecation of a certain component. Jenkins project policy determines exactly what it means. + * + * @since TODO + */ + @Restricted(NoExternalUse.class) + public static final class Deprecation { + public final String url; + public Deprecation(String url) { + this.url = url; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Deprecation that = (Deprecation) o; + return Objects.equals(url, that.url); + } + + @Override + public int hashCode() { + return Objects.hash(url); + } + } + /** * Represents a warning about a certain component, mostly related to known security issues. * @@ -1099,7 +1166,15 @@ public class UpdateSite { } + @Restricted(NoExternalUse.class) + public boolean isDeprecated() { + return getDeprecation() != null; + } + @Restricted(NoExternalUse.class) + public UpdateSite.Deprecation getDeprecation() { + return Jenkins.get().getUpdateCenter().getSite(sourceId).getData().getDeprecations().get(this.name); + } public String getDisplayName() { String displayName; @@ -1414,15 +1489,6 @@ public class UpdateSite { return warnings; } - /** - * Is this plugin labeled deprecated? - * @return {@code true} when plugin contains deprecated in categories, otherwise {@code false}. - * @since TODO - */ - public boolean isDeprecated() { - return categories != null && Arrays.asList(categories).contains("deprecated"); - } - /** * @since 2.40 */ diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly index fdd14ef538..5e40379e33 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly @@ -27,13 +27,13 @@ THE SOFTWARE.
${%DeprecatedPlugins}
- + -
${p.longName} ${p.version}
+
${p.displayName}
-
${p.longName} ${p.version}
+
${p.displayName}}
diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties index 837b2baad1..94a77a83dc 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties @@ -24,4 +24,4 @@ DeprecatedPlugins=There are deprecated plugins installed DeprecatedPluginsDescription=\ In general, this means that these plugins are either obsolete, no longer being developed, or may no longer work.
\ - See the plugin's documentation for further information about the cause for the deprecation, and suggestions on how to proceed. + See the linked web pages for further information about the cause for the deprecation, and suggestions on how to proceed. diff --git a/core/src/main/resources/hudson/PluginManager/installed.jelly b/core/src/main/resources/hudson/PluginManager/installed.jelly index 6291241e99..e8b169de09 100644 --- a/core/src/main/resources/hudson/PluginManager/installed.jelly +++ b/core/src/main/resources/hudson/PluginManager/installed.jelly @@ -133,8 +133,8 @@ THE SOFTWARE.
-
- ${%deprecationWarning} +
+ ${%deprecationWarning(p.getDeprecations().get(0).url)}
diff --git a/core/src/main/resources/hudson/PluginManager/installed.properties b/core/src/main/resources/hudson/PluginManager/installed.properties index 5905200350..15f4137a46 100644 --- a/core/src/main/resources/hudson/PluginManager/installed.properties +++ b/core/src/main/resources/hudson/PluginManager/installed.properties @@ -24,10 +24,7 @@ requires.restart=This Jenkins instance requires a restart. Changing the state of detached-disable=This plugin may not be safe to disable detached-uninstall=This plugin may not be safe to uninstall detached-possible-dependents=Its functionality was at one point moved out of Jenkins core, and another plugin with a core dependency predating the split may be relying on it implicitly. -deprecationWarning=\ - Warning: This plugin has been marked as deprecated.
\ - In general, this means that this plugin is either obsolete, no longer being developed, or may no longer work.
\ - This plugin may be safe to uninstall +deprecationWarning=This plugin is deprecated. In general, this means that it is either obsolete, no longer being developed, or may no longer work. Learn more. securityWarning=\ Warning: The currently installed plugin version may not be safe to use. Please review the following security notices: adoptThisPlugin=\ diff --git a/core/src/main/resources/hudson/PluginManager/table.jelly b/core/src/main/resources/hudson/PluginManager/table.jelly index aa63130e4e..de6927d9d2 100644 --- a/core/src/main/resources/hudson/PluginManager/table.jelly +++ b/core/src/main/resources/hudson/PluginManager/table.jelly @@ -160,6 +160,11 @@ THE SOFTWARE.
+ +
+ ${%deprecationWarning(p.getDeprecation().url)} +
+
${%adoptThisPlugin} diff --git a/core/src/main/resources/hudson/PluginManager/table.properties b/core/src/main/resources/hudson/PluginManager/table.properties index d9fe7d043f..402c8d8970 100644 --- a/core/src/main/resources/hudson/PluginManager/table.properties +++ b/core/src/main/resources/hudson/PluginManager/table.properties @@ -54,3 +54,4 @@ adoptThisPlugin=\ loading=Plugin list is loading... instructions=Use the search field above to search for available plugins. +deprecationWarning=This plugin is deprecated. In general, this means that it is either obsolete, no longer being developed, or may no longer work. Learn more. From 2f60a6955586ab27578e9fa946010a2a703525e5 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sun, 3 May 2020 22:11:32 +0200 Subject: [PATCH 15/24] Add test --- .../test/java/hudson/PluginManagerTest.java | 64 +++++++++++++++ .../plugins/deprecations-update-center.json | 81 +++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 test/src/test/resources/plugins/deprecations-update-center.json diff --git a/test/src/test/java/hudson/PluginManagerTest.java b/test/src/test/java/hudson/PluginManagerTest.java index bb9ce486b8..41d842d755 100644 --- a/test/src/test/java/hudson/PluginManagerTest.java +++ b/test/src/test/java/hudson/PluginManagerTest.java @@ -40,14 +40,18 @@ import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; +import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; +import java.util.Set; import java.util.concurrent.Future; import jenkins.ClassLoaderReflectionToolkit; import jenkins.RestartRequiredException; import jenkins.model.GlobalConfiguration; +import jenkins.model.Jenkins; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.io.FileUtils; @@ -604,4 +608,64 @@ public class PluginManagerTest { dynamicLoad("jenkins-50336.hpi"); assertTrue(ExtensionList.lookup(GlobalConfiguration.class).stream().anyMatch(gc -> "io.jenkins.plugins.MyGlobalConfiguration".equals(gc.getClass().getName()))); } + + /* + credentials - present in update-center.json, not deprecated + htmlpublisher - not in update-center.json, not deprecated + icon-shim, present in update-center.json, deprecated via label and top-level list + token-macro, present in update-center.json, deprecated via label only + variant, not in update-center.json, deprecated via top-level list + */ + @Test + @WithPlugin({"credentials.hpi", "htmlpublisher.jpi", "icon-shim.hpi", "token-macro.hpi", "variant.hpi"}) + public void testDeprecationNotices() throws Exception { + PersistedList sites = r.jenkins.getUpdateCenter().getSites(); + sites.clear(); + URL url = PluginManagerTest.class.getResource("/plugins/deprecations-update-center.json"); + UpdateSite site = new UpdateSite(UpdateCenter.ID_DEFAULT, url.toString()); + sites.add(site); + + assertEquals(FormValidation.ok(), site.updateDirectlyNow(false)); + assertNotNull(site.getData()); + + assertTrue(ExtensionList.lookupSingleton(PluginManager.PluginDeprecationMonitor.class).isActivated()); + + final PluginManager pm = Jenkins.get().getPluginManager(); + + final PluginWrapper credentials = pm.getPlugin("credentials"); + Objects.requireNonNull(credentials); + assertFalse(credentials.isDeprecated()); + assertTrue(credentials.getDeprecations().isEmpty()); + + final PluginWrapper htmlpublisher = pm.getPlugin("htmlpublisher"); + Objects.requireNonNull(htmlpublisher); + assertFalse(htmlpublisher.isDeprecated()); + assertTrue(htmlpublisher.getDeprecations().isEmpty()); + + final PluginWrapper iconShim = pm.getPlugin("icon-shim"); + Objects.requireNonNull(iconShim); + assertTrue(iconShim.isDeprecated()); + Set deprecations = iconShim.getDeprecations(); + assertEquals(1, deprecations.size()); + List deprecationList = new ArrayList<>(deprecations); + assertEquals("https://jenkins.io/deprecations/icon-shim/", deprecationList.get(0).url); + assertEquals("https://wiki.jenkins-ci.org/display/JENKINS/Icon+Shim+Plugin", iconShim.getInfo().wiki); + + final PluginWrapper tokenMacro = pm.getPlugin("token-macro"); + Objects.requireNonNull(tokenMacro); + assertTrue(tokenMacro.isDeprecated()); + deprecations = tokenMacro.getDeprecations(); + assertEquals(1, deprecations.size()); + deprecationList = new ArrayList<>(deprecations); + assertEquals("https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin", deprecationList.get(0).url); + + final PluginWrapper variant = pm.getPlugin("variant"); + Objects.requireNonNull(variant); + assertTrue(variant.isDeprecated()); + deprecations = variant.getDeprecations(); + assertEquals(1, deprecations.size()); + deprecationList = new ArrayList<>(deprecations); + assertEquals("https://jenkins.io/deprecations/variant/", deprecationList.get(0).url); + assertNull(variant.getInfo()); + } } diff --git a/test/src/test/resources/plugins/deprecations-update-center.json b/test/src/test/resources/plugins/deprecations-update-center.json new file mode 100644 index 0000000000..1817fc5e13 --- /dev/null +++ b/test/src/test/resources/plugins/deprecations-update-center.json @@ -0,0 +1,81 @@ +updateCenter.post( +{"connectionCheckUrl":"http://www.google.com/", + "core": { + "buildDate": "Dec 31, 1969", + "name": "core", + "url": "jenkins.war", + "version": "23" + }, + "id": "default", + "plugins": { + "credentials": { + "buildDate": "Apr 04, 2016", + "dependencies": [ + { + "name": "icon-shim", + "optional": false, + "version":"2.0.2" + } + ], + "developers": [], + "excerpt": "This plugin allows you to store credentials in Jenkins.", + "gav": "org.jenkins-ci.plugins:credentials:1.27", + "labels": [], + "name": "credentials", + "previousTimestamp": "2016-03-24T01:19:58.00Z", + "previousVersion": "1.26", + "releaseTimestamp": "2016-04-04T16:26:54.00Z", + "requiredCore": "1.565", + "scm": "github.com", + "sha1": "XWJpfL8B2x7qrISJg7IY2ZTPxFk=", + "title": "Credentials Plugin", + "url": "credentials.hpi", + "version": "1.27", + "wiki": "https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Plugin" + }, + "icon-shim": { + "buildDate": "Feb 23, 2016", + "dependencies": [], + "developers": [], + "excerpt": "This plugin allows other Jenkins plugins to take advantage of the tag. ", + "gav": "org.jenkins-ci.plugins.icon-shim:icon-shim:2.0.3", + "labels": ["deprecated"], + "name": "icon-shim", + "previousTimestamp": "2016-01-09T20:01:12.00Z", + "previousVersion": "2.0.2", + "releaseTimestamp": "2016-02-23T23:08:18.00Z", + "requiredCore": "1.609", + "scm": "github.com", + "sha1": "umtSUbNwIuqU6JGEQcBxqFt1X24=", + "title": "Icon Shim Plugin", + "url": "icon-shim.hpi", + "version": "2.0.3", + "wiki": "https://wiki.jenkins-ci.org/display/JENKINS/Icon+Shim+Plugin" + }, + "token-macro": { + "buildDate": "Dec 14, 2015", + "dependencies": [], + "developers": [], + "excerpt": "This plugin adds reusable macro expansion capability for other plugins to use", + "gav": "org.jenkins-ci.plugins:token-macro:1.12.1", + "labels": ["deprecated"], + "name": "token-macro", + "previousTimestamp": "2015-12-11T08:27:18.00Z", + "previousVersion": "1.12", + "releaseTimestamp": "2015-12-14T18:07:56.00Z", + "requiredCore": "1.609.2", + "scm": "github.com", + "sha1": "TV61PGo+od75URp3maLGUFJ768k=", + "title": "Token Macro Plugin", + "url": "token-macro.hpi", + "version": "1.9", + "wiki": "https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin" + } + }, + "deprecations": { + "icon-shim": "https://jenkins.io/deprecations/icon-shim/", + "variant": "https://jenkins.io/deprecations/variant/", + }, + "updateCenterVersion": 1 +} +); From f0ef947bf42e873b4d8b9be5f557f957eff75f70 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sun, 3 May 2020 22:39:09 +0200 Subject: [PATCH 16/24] Make this a list to allow direct element access --- core/src/main/java/hudson/PluginWrapper.java | 4 ++-- .../resources/hudson/PluginManager/installed.jelly | 1 + test/src/test/java/hudson/PluginManagerTest.java | 11 ++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index 32c67e771d..0442248c2d 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -1303,9 +1303,9 @@ public class PluginWrapper implements Comparable, ModelObject { } @Restricted(NoExternalUse.class) - public Set getDeprecations() { + public List getDeprecations() { /* Would be much nicer to go through getInfoFromAllSites but that only works for currently published plugins */ - Set deprecations = new HashSet<>(); + List deprecations = new ArrayList<>(); for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) { for (Map.Entry entry : site.getData().getDeprecations().entrySet()) { if (entry.getKey().equals(this.shortName)) { diff --git a/core/src/main/resources/hudson/PluginManager/installed.jelly b/core/src/main/resources/hudson/PluginManager/installed.jelly index e8b169de09..c911933422 100644 --- a/core/src/main/resources/hudson/PluginManager/installed.jelly +++ b/core/src/main/resources/hudson/PluginManager/installed.jelly @@ -134,6 +134,7 @@ THE SOFTWARE.
+ ${%deprecationWarning(p.getDeprecations().get(0).url)}
diff --git a/test/src/test/java/hudson/PluginManagerTest.java b/test/src/test/java/hudson/PluginManagerTest.java index 41d842d755..684f0ef55c 100644 --- a/test/src/test/java/hudson/PluginManagerTest.java +++ b/test/src/test/java/hudson/PluginManagerTest.java @@ -645,10 +645,9 @@ public class PluginManagerTest { final PluginWrapper iconShim = pm.getPlugin("icon-shim"); Objects.requireNonNull(iconShim); assertTrue(iconShim.isDeprecated()); - Set deprecations = iconShim.getDeprecations(); + List deprecations = iconShim.getDeprecations(); assertEquals(1, deprecations.size()); - List deprecationList = new ArrayList<>(deprecations); - assertEquals("https://jenkins.io/deprecations/icon-shim/", deprecationList.get(0).url); + assertEquals("https://jenkins.io/deprecations/icon-shim/", deprecations.get(0).url); assertEquals("https://wiki.jenkins-ci.org/display/JENKINS/Icon+Shim+Plugin", iconShim.getInfo().wiki); final PluginWrapper tokenMacro = pm.getPlugin("token-macro"); @@ -656,16 +655,14 @@ public class PluginManagerTest { assertTrue(tokenMacro.isDeprecated()); deprecations = tokenMacro.getDeprecations(); assertEquals(1, deprecations.size()); - deprecationList = new ArrayList<>(deprecations); - assertEquals("https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin", deprecationList.get(0).url); + assertEquals("https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin", deprecations.get(0).url); final PluginWrapper variant = pm.getPlugin("variant"); Objects.requireNonNull(variant); assertTrue(variant.isDeprecated()); deprecations = variant.getDeprecations(); assertEquals(1, deprecations.size()); - deprecationList = new ArrayList<>(deprecations); - assertEquals("https://jenkins.io/deprecations/variant/", deprecationList.get(0).url); + assertEquals("https://jenkins.io/deprecations/variant/", deprecations.get(0).url); assertNull(variant.getInfo()); } } From 37e02b3db7076f98f28ab8c7aeec93d6875809ed Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sun, 3 May 2020 22:40:16 +0200 Subject: [PATCH 17/24] This isn't a critical problem so go with warning style, rephrase label --- .../hudson/PluginManager/PluginDeprecationMonitor/message.jelly | 2 +- .../PluginManager/PluginDeprecationMonitor/message.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly index 5e40379e33..a6df7ce2d1 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly @@ -24,7 +24,7 @@ THE SOFTWARE. -
+
${%DeprecatedPlugins}
diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties index 94a77a83dc..e093ad7210 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.properties @@ -21,7 +21,7 @@ # THE SOFTWARE. -DeprecatedPlugins=There are deprecated plugins installed +DeprecatedPlugins=The following installed plugins are deprecated DeprecatedPluginsDescription=\ In general, this means that these plugins are either obsolete, no longer being developed, or may no longer work.
\ See the linked web pages for further information about the cause for the deprecation, and suggestions on how to proceed. From f8c12c714b12baee0ed1b4b435b9a8e08cc62549 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sun, 3 May 2020 22:48:54 +0200 Subject: [PATCH 18/24] Add an intermediate JSON object in the UC data for extensibility --- core/src/main/java/hudson/model/UpdateSite.java | 3 ++- .../test/resources/plugins/deprecations-update-center.json | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 7f0acaf9e7..d37cbe92b8 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -597,7 +597,8 @@ public class UpdateSite { for (Iterator it = deprecations.keys(); it.hasNext(); ) { try { String pluginId = it.next().toString(); - String referenceUrl = deprecations.getString(pluginId); + JSONObject entry = deprecations.getJSONObject(pluginId); // additional level of indirection to support future extensibility + String referenceUrl = entry.getString("url"); this.deprecations.put(pluginId, new Deprecation(referenceUrl)); } catch (JSONException ex) { LOGGER.log(Level.WARNING, "Failed to parse JSON for deprecation", ex); diff --git a/test/src/test/resources/plugins/deprecations-update-center.json b/test/src/test/resources/plugins/deprecations-update-center.json index 1817fc5e13..9fab1d35e8 100644 --- a/test/src/test/resources/plugins/deprecations-update-center.json +++ b/test/src/test/resources/plugins/deprecations-update-center.json @@ -73,8 +73,8 @@ updateCenter.post( } }, "deprecations": { - "icon-shim": "https://jenkins.io/deprecations/icon-shim/", - "variant": "https://jenkins.io/deprecations/variant/", + "icon-shim": { "url": "https://jenkins.io/deprecations/icon-shim/" }, + "variant": { "url": "https://jenkins.io/deprecations/variant/" } }, "updateCenterVersion": 1 } From 56c11a3f79c9de817a8045721eafaf34d7710705 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Mon, 4 May 2020 10:20:22 +0200 Subject: [PATCH 19/24] Make 'deprecated' a meta label (not shown in the regular label list) --- core/src/main/java/hudson/PluginManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index e0914220d4..ba0ccd364a 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -2280,7 +2280,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas @Restricted(DoNotUse.class) // Used from table.jelly public boolean isMetaLabel(String label) { - return "adopt-this-plugin".equals(label); + return "adopt-this-plugin".equals(label) || "deprecated".equals(label); } @Restricted(DoNotUse.class) // Used from table.jelly From 1821fd0016a8f1977de1e60994232b09e3b27db9 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Mon, 4 May 2020 12:57:21 +0200 Subject: [PATCH 20/24] Make parsing this safer --- core/src/main/java/hudson/model/UpdateSite.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index d37cbe92b8..4b86e39a1c 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -598,9 +598,13 @@ public class UpdateSite { try { String pluginId = it.next().toString(); JSONObject entry = deprecations.getJSONObject(pluginId); // additional level of indirection to support future extensibility - String referenceUrl = entry.getString("url"); - this.deprecations.put(pluginId, new Deprecation(referenceUrl)); - } catch (JSONException ex) { + if (entry != null) { + String referenceUrl = entry.getString("url"); + if (referenceUrl != null) { + this.deprecations.put(pluginId, new Deprecation(referenceUrl)); + } + } + } catch (RuntimeException ex) { LOGGER.log(Level.WARNING, "Failed to parse JSON for deprecation", ex); } } From ab97dbbdaf928474852614bdfcf5fa40dff56d60 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Tue, 5 May 2020 10:26:42 +0200 Subject: [PATCH 21/24] Null safety with labels array --- core/src/main/java/hudson/model/UpdateSite.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 4b86e39a1c..f38c9955c7 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -625,9 +625,11 @@ public class UpdateSite { // compatibility with update sites that have no separate 'deprecated' top-level entry. // Also do this even if there are deprecations to potentially allow limiting the top-level entry to overridden URLs. - if (Arrays.asList(p.categories).contains("deprecated")) { - if (!this.deprecations.containsKey(p.name)) { - this.deprecations.put(p.name, new Deprecation(p.wiki)); + if (p.categories != null) { + if (Arrays.asList(p.categories).contains("deprecated")) { + if (!this.deprecations.containsKey(p.name)) { + this.deprecations.put(p.name, new Deprecation(p.wiki)); + } } } } From 9ae93b67a0a23fd7b52b2a2b780708fc631afed0 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Tue, 26 May 2020 21:40:24 +0200 Subject: [PATCH 22/24] Link to the deprecation URL, not the plugin URL --- core/src/main/java/hudson/PluginManager.java | 5 +++-- .../PluginDeprecationMonitor/message.jelly | 11 ++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index ba0ccd364a..db40218db2 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -145,6 +145,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Future; +import java.util.function.Function; import java.util.function.Supplier; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -2257,10 +2258,10 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas return !getDeprecatedPlugins().isEmpty(); } - public List getDeprecatedPlugins() { + public Map getDeprecatedPlugins() { return Jenkins.get().getPluginManager().getPlugins().stream() .filter(PluginWrapper::isDeprecated) - .collect(Collectors.toList()); + .collect(Collectors.toMap(Function.identity(), it -> it.getDeprecations().get(0).url)); } } diff --git a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly index a6df7ce2d1..1b4dc8e8a9 100644 --- a/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly +++ b/core/src/main/resources/hudson/PluginManager/PluginDeprecationMonitor/message.jelly @@ -27,15 +27,8 @@ THE SOFTWARE.
${%DeprecatedPlugins}
- - - -
${p.displayName}
-
- -
${p.displayName}}
-
-
+ +
${e.key.displayName}

${%DeprecatedPluginsDescription}

From 102771d5f80d199daed8ee3b92f29a9c9adc9952 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sat, 20 Jun 2020 20:59:39 +0200 Subject: [PATCH 23/24] Add issue reference --- test/src/test/java/hudson/PluginManagerTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/src/test/java/hudson/PluginManagerTest.java b/test/src/test/java/hudson/PluginManagerTest.java index 0a00bba2a4..a0839d5c1a 100644 --- a/test/src/test/java/hudson/PluginManagerTest.java +++ b/test/src/test/java/hudson/PluginManagerTest.java @@ -623,6 +623,7 @@ public class PluginManagerTest { variant, not in update-center.json, deprecated via top-level list */ @Test + @Issue("JENKINS-59136") @WithPlugin({"credentials.hpi", "htmlpublisher.jpi", "icon-shim.hpi", "token-macro.hpi", "variant.hpi"}) public void testDeprecationNotices() throws Exception { PersistedList sites = r.jenkins.getUpdateCenter().getSites(); From 1610ba042e3467486ffdea890a45c80a97101231 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Fri, 10 Jul 2020 15:35:22 +0200 Subject: [PATCH 24/24] Add Javadoc --- core/src/main/java/hudson/model/UpdateSite.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 3797837480..6938e62a2e 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -846,6 +846,11 @@ public class UpdateSite { */ @Restricted(NoExternalUse.class) public static final class Deprecation { + /** + * URL for this deprecation. + * + * Jenkins will show a link to this URL when displaying the deprecation message. + */ public final String url; public Deprecation(String url) { this.url = url;