]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3895 fix the default values of sonar.dryRun.excludePlugins/includePlugins
authorSimon Brandhof <simon.brandhof@gmail.com>
Mon, 26 Nov 2012 23:38:18 +0000 (00:38 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Mon, 26 Nov 2012 23:38:18 +0000 (00:38 +0100)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java

index 43176b47b83d32d4bb48d65862b32a2d6a1ece85..0592005e12ec2fdbe07ab63848fe00889c72397b 100644 (file)
@@ -332,13 +332,14 @@ import java.util.List;
   @Property(
     key = CoreProperties.DRY_RUN_INCLUDE_PLUGINS,
     name = "Plugins accepted for dry run",
+    defaultValue = CoreProperties.DRY_RUN_INCLUDE_PLUGINS_DEFAULT_VALUE,
     global = true, project = false,
     category = CoreProperties.CATEGORY_GENERAL),
   @Property(
     key = CoreProperties.DRY_RUN_EXCLUDE_PLUGINS,
     name = "Plugins excluded for dry run",
     global = true, project = false,
-    defaultValue = "devcockpit,pdfreport,report,scmactivity,views",
+    defaultValue = CoreProperties.DRY_RUN_EXCLUDE_PLUGINS_DEFAULT_VALUE,
     category = CoreProperties.CATEGORY_GENERAL),
   @Property(
     key = "sonar.dryRun.export.path",
index c0dddd09215f46720048d9d6031d436899d24f56..1ea9307364d2701bec92027a1688c3598c3d5dc0 100644 (file)
@@ -122,8 +122,12 @@ public class BatchPluginRepository implements PluginRepository {
         blacks.addAll(Arrays.asList(settings.getStringArray(CoreProperties.BATCH_EXCLUDE_PLUGINS)));
       }
       if (settings.getBoolean(CoreProperties.DRY_RUN)) {
-        whites.addAll(Arrays.asList(settings.getStringArray(CoreProperties.DRY_RUN_INCLUDE_PLUGINS)));
-        blacks.addAll(Arrays.asList(settings.getStringArray(CoreProperties.DRY_RUN_EXCLUDE_PLUGINS)));
+        // These default values are not supported by Settings because the class CorePlugin
+        // is not loaded yet.
+        whites.addAll(propertyValues(settings,
+          CoreProperties.DRY_RUN_INCLUDE_PLUGINS, CoreProperties.DRY_RUN_INCLUDE_PLUGINS_DEFAULT_VALUE));
+        blacks.addAll(propertyValues(settings,
+                  CoreProperties.DRY_RUN_EXCLUDE_PLUGINS, CoreProperties.DRY_RUN_EXCLUDE_PLUGINS_DEFAULT_VALUE));
       }
       if (!whites.isEmpty()) {
         LOG.info("Include plugins: " + Joiner.on(", ").join(whites));
@@ -133,6 +137,11 @@ public class BatchPluginRepository implements PluginRepository {
       }
     }
 
+    static List<String> propertyValues(Settings settings, String key, String defaultValue) {
+      String s = StringUtils.defaultIfEmpty(settings.getString(key), defaultValue);
+      return Arrays.asList(StringUtils.split(s, ","));
+    }
+
     boolean accepts(String pluginKey) {
       if (CORE_PLUGIN.equals(pluginKey) || ENGLISH_PACK_PLUGIN.equals(pluginKey)) {
         return true;
index f94c6d7bc8a6c704f43a1c0a45a75757c88c3336..9ad4e496a477e39ee327cfbaf4bffed8b2b1345c 100644 (file)
@@ -161,15 +161,18 @@ public interface CoreProperties {
   String BATCH_INCLUDE_PLUGINS = "sonar.includePlugins";
   String BATCH_EXCLUDE_PLUGINS = "sonar.excludePlugins";
 
+
   /**
    * @since 3.4
    */
   String DRY_RUN_INCLUDE_PLUGINS = "sonar.dryRun.includePlugins";
+  String DRY_RUN_INCLUDE_PLUGINS_DEFAULT_VALUE = "";
 
   /**
    * @since 3.4
    */
   String DRY_RUN_EXCLUDE_PLUGINS = "sonar.dryRun.excludePlugins";
+  String DRY_RUN_EXCLUDE_PLUGINS_DEFAULT_VALUE = "devcockpit,pdfreport,report,scmactivity,views";
 
   /**
    * @since 2.10