From e0488fa87e61469a8c68340857f3151b359112e6 Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 14 Oct 2010 14:04:00 +0200 Subject: [PATCH] Plugins: Allow to place "extracted" plugins under the `plugins` directory, closes #428. --- .../elasticsearch/plugins/PluginsService.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/PluginsService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/PluginsService.java index b7f040fe922..8b1615dca48 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -164,6 +164,23 @@ public class PluginsService extends AbstractComponent { File[] pluginsFiles = pluginsFile.listFiles(); for (File pluginFile : pluginsFiles) { if (!pluginFile.getName().endsWith(".zip")) { + if (pluginFile.isDirectory()) { + logger.trace("--- adding expanded plugin [" + pluginFile.getAbsolutePath() + "]"); + try { + // add the root + addURL.invoke(classLoader, pluginFile.toURI().toURL()); + // if there are jars in it, add it as well + for (File jarToAdd : pluginFile.listFiles()) { + if (!(jarToAdd.getName().endsWith(".jar") || jarToAdd.getName().endsWith(".zip"))) { + continue; + } + addURL.invoke(classLoader, jarToAdd.toURI().toURL()); + } + } catch (Exception e) { + logger.warn("failed to add plugin [" + pluginFile + "]", e); + } + } + continue; } if (logger.isTraceEnabled()) {