diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-03-18 23:24:30 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-03-18 23:24:30 +0100 |
commit | f5bd11bbc574fe1dbb80e7dfe2f66bcaeb60ddbc (patch) | |
tree | 36442c6e5f7e52ad498dd52b62d39172bd0d8460 | |
parent | 69314f91c512f9b652fdd4184184cf59f8743881 (diff) | |
download | sonarqube-f5bd11bbc574fe1dbb80e7dfe2f66bcaeb60ddbc.tar.gz sonarqube-f5bd11bbc574fe1dbb80e7dfe2f66bcaeb60ddbc.zip |
SONAR-5150 Values of sonar.preview.excludePlugins and sonar.preview.includePlugins should be trimmed
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java | 10 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java | 10 |
2 files changed, 18 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java index e0e366282a1..584ecce1cad 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java @@ -20,6 +20,8 @@ package org.sonar.batch.bootstrap; import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -34,7 +36,11 @@ import org.sonar.core.plugins.RemotePlugin; import java.io.File; import java.text.MessageFormat; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Sets.newHashSet; @@ -154,7 +160,7 @@ 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, ",")); + return Lists.newArrayList(Splitter.on(",").trimResults().split(s)); } boolean accepts(String pluginKey) { diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java index 41a6d0048d5..b1a4eb2a999 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchPluginRepositoryTest.java @@ -222,4 +222,14 @@ public class BatchPluginRepositoryTest { assertThat(filter.whites).containsOnly("cockpit"); assertThat(filter.blacks).containsOnly("views", "checkstyle", "pmd"); } + + @Test + public void inclusions_and_exclusions_should_be_trimmed() { + Settings settings = new Settings() + .setProperty(CoreProperties.BATCH_INCLUDE_PLUGINS, "checkstyle, pmd, findbugs") + .setProperty(CoreProperties.BATCH_EXCLUDE_PLUGINS, "cobertura, pmd"); + BatchPluginRepository.PluginFilter filter = new BatchPluginRepository.PluginFilter(settings, mode); + assertThat(filter.accepts("pmd")).isTrue(); + } + } |