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;
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;
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) {
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();
+ }
+
}