Browse Source

The requires Expression does not print well, instead we get the className. This fix adds a `requiresString` to PluginInfo. (#137)

pull/138/head
Jan Høydahl 8 years ago committed by Decebal Suiu
parent
commit
edbb541b86
  1. 5
      pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java
  2. 11
      pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java
  3. 1
      pf4j/src/test/java/ro/fortsoft/pf4j/PropertiesPluginDescriptorFinderTest.java

5
pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java

@ -703,10 +703,11 @@ public abstract class AbstractPluginManager implements PluginManager {
return true; 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.getPluginId(),
pluginWrapper.getDescriptor().getVersion(), pluginWrapper.getDescriptor().getVersion(),
requires); pluginWrapper.getDescriptor().getRequiresString(),
system);
return false; return false;
} }

11
pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java

@ -37,6 +37,7 @@ public class PluginDescriptor {
private String pluginClass; private String pluginClass;
private Version version; private Version version;
private Expression requires; private Expression requires;
private String requiresString;
private String provider; private String provider;
private List<PluginDependency> dependencies; private List<PluginDependency> dependencies;
private String license; private String license;
@ -81,6 +82,13 @@ public class PluginDescriptor {
return requires; return requires;
} }
/**
* Returns the requires of this plugin as a string.
*/
public String getRequiresString() {
return requiresString;
}
/** /**
* Returns the provider name of this plugin. * Returns the provider name of this plugin.
*/ */
@ -108,7 +116,7 @@ public class PluginDescriptor {
return "PluginDescriptor [pluginId=" + pluginId + ", pluginClass=" return "PluginDescriptor [pluginId=" + pluginId + ", pluginClass="
+ pluginClass + ", version=" + version + ", provider=" + pluginClass + ", version=" + version + ", provider="
+ provider + ", dependencies=" + dependencies + ", description=" + provider + ", dependencies=" + dependencies + ", description="
+ pluginDescription + ", requires=" + requires + ", license=" + pluginDescription + ", requires=" + requiresString + ", license="
+ license + "]"; + license + "]";
} }
@ -133,6 +141,7 @@ public class PluginDescriptor {
} }
void setRequires(String requires) { void setRequires(String requires) {
requiresString = requires;
Parser<Expression> parser = ExpressionParser.newInstance(); Parser<Expression> parser = ExpressionParser.newInstance();
setRequires(parser.parse(requires)); setRequires(parser.parse(requires));
} }

1
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("test-plugin-3", plugin1.getDependencies().get(1).getPluginId());
assertEquals("~1.0", plugin1.getDependencies().get(1).getPluginVersionSupport()); assertEquals("~1.0", plugin1.getDependencies().get(1).getPluginVersionSupport());
assertEquals("Apache-2.0", plugin1.getLicense()); assertEquals("Apache-2.0", plugin1.getLicense());
assertEquals("*", plugin1.getRequiresString());
assertTrue(plugin1.getRequires().interpret(Version.valueOf("1.0.0"))); assertTrue(plugin1.getRequires().interpret(Version.valueOf("1.0.0")));
assertEquals("test-plugin-2", plugin2.getPluginId()); assertEquals("test-plugin-2", plugin2.getPluginId());

Loading…
Cancel
Save