From: Jan Høydahl Date: Mon, 3 Apr 2017 17:39:23 +0000 (+0200) Subject: The requires Expression does not print well, instead we get the className. This fix... X-Git-Tag: release-1.3.0~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=edbb541b86efd5424d5d1fa38713ec42792c88a6;p=pf4j.git The requires Expression does not print well, instead we get the className. This fix adds a `requiresString` to PluginInfo. (#137) --- diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java index c8cb41d..96f2c15 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java @@ -703,10 +703,11 @@ public abstract class AbstractPluginManager implements PluginManager { return true; } - log.warn("Plugin '{}:{}' requires a minimum system version of {}", + log.warn("Plugin '{}:{}' requires a minimum system version of {}, and you have {}", pluginWrapper.getPluginId(), pluginWrapper.getDescriptor().getVersion(), - requires); + pluginWrapper.getDescriptor().getRequiresString(), + system); return false; } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java index aa018a1..17f60af 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java @@ -37,6 +37,7 @@ public class PluginDescriptor { private String pluginClass; private Version version; private Expression requires; + private String requiresString; private String provider; private List dependencies; private String license; @@ -81,6 +82,13 @@ public class PluginDescriptor { return requires; } + /** + * Returns the requires of this plugin as a string. + */ + public String getRequiresString() { + return requiresString; + } + /** * Returns the provider name of this plugin. */ @@ -108,7 +116,7 @@ public class PluginDescriptor { return "PluginDescriptor [pluginId=" + pluginId + ", pluginClass=" + pluginClass + ", version=" + version + ", provider=" + provider + ", dependencies=" + dependencies + ", description=" - + pluginDescription + ", requires=" + requires + ", license=" + + pluginDescription + ", requires=" + requiresString + ", license=" + license + "]"; } @@ -133,6 +141,7 @@ public class PluginDescriptor { } void setRequires(String requires) { + requiresString = requires; Parser parser = ExpressionParser.newInstance(); setRequires(parser.parse(requires)); } diff --git a/pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java b/pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java index ca62770..ddd839b 100644 --- a/pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java +++ b/pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java @@ -79,6 +79,7 @@ public class PropertiesPluginDescriptorFinderTest { assertEquals("test-plugin-3", plugin1.getDependencies().get(1).getPluginId()); assertEquals("~1.0", plugin1.getDependencies().get(1).getPluginVersionSupport()); assertEquals("Apache-2.0", plugin1.getLicense()); + assertEquals("*", plugin1.getRequiresString()); assertTrue(plugin1.getRequires().interpret(Version.valueOf("1.0.0"))); assertEquals("test-plugin-2", plugin2.getPluginId());