|
|
|
@ -92,7 +92,7 @@ public class DefaultPluginManager implements PluginManager {
|
|
|
|
|
/** |
|
|
|
|
* The system version used for comparisons to the plugin requires attribute. |
|
|
|
|
*/ |
|
|
|
|
private PluginVersion systemVersion = PluginVersion.DEFAULT; |
|
|
|
|
private PluginVersion systemVersion = PluginVersion.ZERO; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* The plugins directory is supplied by System.getProperty("pf4j.pluginsDir", "plugins"). |
|
|
|
@ -469,23 +469,20 @@ public class DefaultPluginManager implements PluginManager {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
PluginWrapper pluginWrapper = getPlugin(pluginId); |
|
|
|
|
if (!isPluginValid(pluginWrapper)) { |
|
|
|
|
log.warn("Plugin '{}:{}' can not be enabled", |
|
|
|
|
pluginWrapper.getPluginId(), |
|
|
|
|
pluginWrapper.getDescriptor().getVersion()); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
PluginDescriptor pluginDescriptor = pluginWrapper.getDescriptor(); |
|
|
|
|
PluginState pluginState = pluginWrapper.getPluginState(); |
|
|
|
|
if (PluginState.DISABLED != pluginState) { |
|
|
|
|
log.debug("Plugin plugin '{}:{}' is not disabled", pluginDescriptor.getPluginId(), pluginDescriptor.getVersion()); |
|
|
|
|
log.debug("Plugin '{}:{}' is not disabled", pluginDescriptor.getPluginId(), pluginDescriptor.getVersion()); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
PluginVersion requires = pluginWrapper.getDescriptor().getRequires(); |
|
|
|
|
PluginVersion system = getSystemVersion(); |
|
|
|
|
if (!system.isDefault() && !system.atLeast(requires)) { |
|
|
|
|
log.warn(String.format("Failed to enable plugin `{}:{}` because it requires a minimum system version of %s", |
|
|
|
|
pluginWrapper.getPluginId(), |
|
|
|
|
pluginWrapper.getDescriptor().getVersion(), |
|
|
|
|
requires)); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (disabledPlugins.remove(pluginId)) { |
|
|
|
|
FileUtils.writeLines(disabledPlugins, new File(pluginsDirectory, "disabled.txt")); |
|
|
|
@ -659,6 +656,20 @@ public class DefaultPluginManager implements PluginManager {
|
|
|
|
|
return !enabledPlugins.contains(pluginId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected boolean isPluginValid(PluginWrapper pluginWrapper) { |
|
|
|
|
PluginVersion requires = pluginWrapper.getDescriptor().getRequires(); |
|
|
|
|
PluginVersion system = getSystemVersion(); |
|
|
|
|
if (system.isZero() || system.atLeast(requires)) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.warn(String.format("Plugin '%s:%s' requires a minimum system version of %s", |
|
|
|
|
pluginWrapper.getPluginId(), |
|
|
|
|
pluginWrapper.getDescriptor().getVersion(), |
|
|
|
|
requires)); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected FileFilter createHiddenPluginFilter() { |
|
|
|
|
return new HiddenFilter(); |
|
|
|
|
} |
|
|
|
@ -749,16 +760,10 @@ public class DefaultPluginManager implements PluginManager {
|
|
|
|
|
pluginWrapper.setPluginState(PluginState.DISABLED); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// optionally enforce minimum system version requirements
|
|
|
|
|
PluginVersion requires = pluginWrapper.getDescriptor().getRequires(); |
|
|
|
|
PluginVersion system = getSystemVersion(); |
|
|
|
|
if (!system.isDefault() && !system.atLeast(requires)) { |
|
|
|
|
log.warn(String.format("Disabling plugin '%s:%s' because it requires a minimum system version of %s", |
|
|
|
|
pluginWrapper.getPluginId(), |
|
|
|
|
pluginWrapper.getDescriptor().getVersion(), |
|
|
|
|
requires)); |
|
|
|
|
// validate the plugin
|
|
|
|
|
if (!isPluginValid(pluginWrapper)) { |
|
|
|
|
log.info("Plugin '{}' is disabled", pluginPath); |
|
|
|
|
pluginWrapper.setPluginState(PluginState.DISABLED); |
|
|
|
|
disabledPlugins.add(pluginWrapper.getPluginId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.debug("Created wrapper '{}' for plugin '{}'", pluginWrapper, pluginPath); |
|
|
|
|