From de13888bbd8de8876000c9c1ca9868eb4a9f1dc3 Mon Sep 17 00:00:00 2001 From: Matteo Mara Date: Fri, 22 Dec 2023 10:28:19 +0100 Subject: Revert "SONAR-21197 add a property to enable the download of the required plugins only" This reverts commit fcde75e36903ef10c8f9dfca0f22d57bf19b3281. --- .../org/sonar/scanner/bootstrap/ScannerPluginRepository.java | 11 +++++------ .../sonar/scanner/bootstrap/ScannerPluginRepositoryTest.java | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'sonar-scanner-engine/src') diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java index 4aecad4de72..074079f974e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginRepository.java @@ -40,7 +40,6 @@ import org.sonar.scanner.mediumtest.LocalPlugin; import static java.util.stream.Collectors.toMap; import static org.sonar.api.utils.Preconditions.checkState; -import static org.sonar.core.config.ScannerProperties.PLUGIN_LOADING_OPTIMIZATION_KEY; /** * Orchestrates the installation and loading of plugins @@ -57,7 +56,7 @@ public class ScannerPluginRepository implements PluginRepository, Startable { private Map pluginInstancesByKeys; private Map pluginsByKeys; private Map keysByClassLoader; - private boolean shouldLoadOnlyRequiredPluginsOnStart; + private boolean shouldLoadAllPluginsOnStart; public ScannerPluginRepository(PluginInstaller installer, PluginJarExploder pluginJarExploder, PluginClassLoader loader, Configuration properties) { this.installer = installer; @@ -68,9 +67,9 @@ public class ScannerPluginRepository implements PluginRepository, Startable { @Override public void start() { - shouldLoadOnlyRequiredPluginsOnStart = properties.getBoolean(PLUGIN_LOADING_OPTIMIZATION_KEY).orElse(true); - if (!shouldLoadOnlyRequiredPluginsOnStart) { - LOG.warn("{} is false, so ALL available plugins will be downloaded", PLUGIN_LOADING_OPTIMIZATION_KEY); + shouldLoadAllPluginsOnStart = properties.getBoolean("sonar.plugins.loadAll").orElse(false); + if (shouldLoadAllPluginsOnStart) { + LOG.warn("sonar.plugins.loadAll is true, so ALL available plugins will be downloaded"); pluginsByKeys = new HashMap<>(installer.installAllPlugins()); } else { pluginsByKeys = new HashMap<>(installer.installRequiredPlugins()); @@ -97,7 +96,7 @@ public class ScannerPluginRepository implements PluginRepository, Startable { } public Collection installPluginsForLanguages(Set languageKeys) { - if (!shouldLoadOnlyRequiredPluginsOnStart) { + if (shouldLoadAllPluginsOnStart) { return Collections.emptySet(); } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginRepositoryTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginRepositoryTest.java index a91426dad85..5fdb95cae22 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginRepositoryTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginRepositoryTest.java @@ -47,7 +47,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.sonar.core.config.ScannerProperties.PLUGIN_LOADING_OPTIMIZATION_KEY; public class ScannerPluginRepositoryTest { @@ -91,8 +90,9 @@ public class ScannerPluginRepositoryTest { } @Test - public void should_install_all_plugins_when_downloadOnlyRequired_flag_is_false() { - when(properties.getBoolean(PLUGIN_LOADING_OPTIMIZATION_KEY)).thenReturn(Optional.of(false)); + public void should_install_all_plugins_when_loadall_flag_is_set() { + when(properties.getBoolean("sonar.plugins.loadAll")).thenReturn(Optional.of(true)); + underTest.start(); verify(installer).installAllPlugins(); -- cgit v1.2.3