From: Julien HENRY Date: Thu, 25 Sep 2014 15:07:59 +0000 (+0200) Subject: SONAR-5645 Blacklist SCM Activity plugin X-Git-Tag: 5.0-RC1~840 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9ec029871a41413d38e975a075b6d0997a08da6a;p=sonarqube.git SONAR-5645 Blacklist SCM Activity plugin --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index dbf7b8af7d1..5caa64ee892 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -258,11 +258,12 @@ import java.util.List; @Property( key = CoreProperties.SCM_ENABLED_KEY, defaultValue = "true", - name = "Activation of the SCM Activity step", - description = "This property can be set to false in order to deactivate the SCM Activity step.", + name = "Activation of the SCM Sensor", + description = "This property can be set to false in order to deactivate the SCM Sensor.", module = false, project = true, global = true, + category = CoreProperties.CATEGORY_SCM, type = PropertyType.BOOLEAN ), @Property( @@ -273,7 +274,7 @@ import java.util.List; module = false, project = true, global = false, - type = PropertyType.BOOLEAN + category = CoreProperties.CATEGORY_SCM ) }) public final class CorePlugin extends SonarPlugin { diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java index db2432439cb..5f02a203649 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginJarsInstaller.java @@ -37,9 +37,12 @@ import org.sonar.updatecenter.common.PluginReferential; import java.io.File; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; public class ServerPluginJarsInstaller { @@ -50,9 +53,10 @@ public class ServerPluginJarsInstaller { private final ServerPluginJarInstaller installer; private final Map pluginByKeys = Maps.newHashMap(); private final ServerUpgradeStatus serverUpgradeStatus; + private final static Set BLACKLISTED_PLUGINS = new HashSet(Arrays.asList("scmactivity")); public ServerPluginJarsInstaller(Server server, ServerUpgradeStatus serverUpgradeStatus, - DefaultServerFileSystem fs, ServerPluginJarInstaller installer) { + DefaultServerFileSystem fs, ServerPluginJarInstaller installer) { this.server = server; this.serverUpgradeStatus = serverUpgradeStatus; this.fs = fs; @@ -85,18 +89,26 @@ public class ServerPluginJarsInstaller { for (File file : fs.getUserPlugins()) { DefaultPluginMetadata metadata = installer.extractMetadata(file, false); if (StringUtils.isNotBlank(metadata.getKey())) { - PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata); - if (existing != null) { - throw MessageException.of(String.format("Found two files for the same plugin '%s': %s and %s", - metadata.getKey(), metadata.getFile().getName(), existing.getFile().getName())); - } + loadInstalledPlugin(metadata); + } + } + } + + private void loadInstalledPlugin(DefaultPluginMetadata metadata) { + if (BLACKLISTED_PLUGINS.contains(metadata.getKey())) { + LOG.warn("Plugin {} is blacklisted. Please uninstall it.", metadata.getName()); + } else { + PluginMetadata existing = pluginByKeys.put(metadata.getKey(), metadata); + if (existing != null) { + throw MessageException.of(String.format("Found two files for the same plugin '%s': %s and %s", + metadata.getKey(), metadata.getFile().getName(), existing.getFile().getName())); } } } private void moveDownloadedPlugins() { if (fs.getDownloadedPluginsDir().exists()) { - Collection sourceFiles = FileUtils.listFiles(fs.getDownloadedPluginsDir(), new String[]{"jar"}, false); + Collection sourceFiles = FileUtils.listFiles(fs.getDownloadedPluginsDir(), new String[] {"jar"}, false); for (File sourceFile : sourceFiles) { overridePlugin(sourceFile, true); } @@ -116,7 +128,6 @@ public class ServerPluginJarsInstaller { } } - private void overridePlugin(File sourceFile, boolean deleteSource) { File destDir = fs.getUserPluginsDir(); File destFile = new File(destDir, sourceFile.getName()); @@ -180,7 +191,7 @@ public class ServerPluginJarsInstaller { public List getUninstalls() { List names = Lists.newArrayList(); if (fs.getTrashPluginsDir().exists()) { - List files = (List) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[]{"jar"}, false); + List files = (List) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[] {"jar"}, false); for (File file : files) { names.add(file.getName()); } @@ -190,7 +201,7 @@ public class ServerPluginJarsInstaller { public void cancelUninstalls() { if (fs.getTrashPluginsDir().exists()) { - List files = (List) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[]{"jar"}, false); + List files = (List) FileUtils.listFiles(fs.getTrashPluginsDir(), new String[] {"jar"}, false); for (File file : files) { try { FileUtils.moveFileToDirectory(file, fs.getUserPluginsDir(), false); diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 891c4e034c4..a269b014eab 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -942,7 +942,7 @@ property.error.notBoolean=Valid options are "true" and "false" property.error.notInteger=Only digits are allowed property.error.notFloat=Not a floating point number property.error.notInOptions=Not a valid option - +property.category.scm=SCM #------------------------------------------------------------------------------ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index c9b6c5e7b20..e13f6c3581d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -536,6 +536,11 @@ public interface CoreProperties { */ String LANGUAGE_SPECIFIC_PARAMETERS_SIZE_METRIC_KEY = "size_metric"; + /** + * @since 5.0 + */ + String CATEGORY_SCM = "scm"; + /** * @since 5.0 */