diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2020-08-27 10:16:20 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2020-09-18 20:07:13 +0000 |
commit | d94d9a9f4a298fcd1eee968f6f4949bd57fd9672 (patch) | |
tree | ca7561c0e7eab37d65a0977edbb343ef73549f7a /server/sonar-ce | |
parent | 50b8c3024111a9e6b99ef94dc04a79684cae5253 (diff) | |
download | sonarqube-d94d9a9f4a298fcd1eee968f6f4949bd57fd9672.tar.gz sonarqube-d94d9a9f4a298fcd1eee968f6f4949bd57fd9672.zip |
SONAR-13644 load bundled plugins from 'lib/extension' directory
Diffstat (limited to 'server/sonar-ce')
4 files changed, 19 insertions, 9 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/CePluginJarExploder.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/CePluginJarExploder.java index 1560d042832..18959e76b31 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/CePluginJarExploder.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/CePluginJarExploder.java @@ -28,7 +28,7 @@ import org.sonar.core.platform.PluginInfo; import org.sonar.core.platform.PluginJarExploder; /** - * Explodes the plugin JARs of extensions/plugins/ into a temporary directory + * Explodes the plugin JARs of extensions/plugins or lib/extensions into a temporary directory * dedicated to compute engine. */ public class CePluginJarExploder extends PluginJarExploder { diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/CePluginRepository.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/CePluginRepository.java index 14b11ada9ca..4c9476647ce 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/CePluginRepository.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/CePluginRepository.java @@ -64,12 +64,17 @@ public class CePluginRepository implements PluginRepository, Startable { @Override public void start() { Loggers.get(getClass()).info("Load plugins"); - for (File file : listJarFiles(fs.getInstalledPluginsDir())) { + registerPluginsFromDir(fs.getInstalledBundledPluginsDir()); + registerPluginsFromDir(fs.getInstalledExternalPluginsDir()); + pluginInstancesByKeys.putAll(loader.load(pluginInfosByKeys)); + started.set(true); + } + + private void registerPluginsFromDir(File pluginsDir) { + for (File file : listJarFiles(pluginsDir)) { PluginInfo info = PluginInfo.create(file); pluginInfosByKeys.put(info.getKey(), info); } - pluginInstancesByKeys.putAll(loader.load(pluginInfosByKeys)); - started.set(true); } @Override diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java index 94de2f97a88..e7136f2c67f 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginJarExploderTest.java @@ -125,7 +125,12 @@ public class CePluginJarExploderTest { } @Override - public File getInstalledPluginsDir() { + public File getInstalledExternalPluginsDir() { + throw new UnsupportedOperationException(); + } + + @Override + public File getInstalledBundledPluginsDir() { throw new UnsupportedOperationException(); } diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java index ef691a2150f..047eebf6ead 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/CePluginRepositoryTest.java @@ -58,7 +58,7 @@ public class CePluginRepositoryTest { @Test public void empty_plugins() throws Exception { // empty folder - when(fs.getInstalledPluginsDir()).thenReturn(temp.newFolder()); + when(fs.getInstalledExternalPluginsDir()).thenReturn(temp.newFolder()); underTest.start(); @@ -69,7 +69,7 @@ public class CePluginRepositoryTest { @Test public void load_plugins() { String pluginKey = "test"; - when(fs.getInstalledPluginsDir()).thenReturn(new File("src/test/plugins/sonar-test-plugin/target")); + when(fs.getInstalledExternalPluginsDir()).thenReturn(new File("src/test/plugins/sonar-test-plugin/target")); underTest.start(); @@ -85,7 +85,7 @@ public class CePluginRepositoryTest { expectedException.expectMessage("Plugin [foo] does not exist"); // empty folder - when(fs.getInstalledPluginsDir()).thenReturn(temp.newFolder()); + when(fs.getInstalledExternalPluginsDir()).thenReturn(temp.newFolder()); underTest.start(); underTest.getPluginInfo("foo"); } @@ -96,7 +96,7 @@ public class CePluginRepositoryTest { expectedException.expectMessage("Plugin [foo] does not exist"); // empty folder - when(fs.getInstalledPluginsDir()).thenReturn(temp.newFolder()); + when(fs.getInstalledExternalPluginsDir()).thenReturn(temp.newFolder()); underTest.start(); underTest.getPluginInstance("foo"); } |