aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java14
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/BatchPluginRepositoryTest.java25
2 files changed, 38 insertions, 1 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java b/sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java
index 51a2e095380..6ee190fabec 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java
@@ -22,6 +22,7 @@ package org.sonar.batch;
import com.google.common.collect.HashMultimap;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
import org.picocontainer.MutablePicoContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -113,7 +114,18 @@ public class BatchPluginRepository extends AbstractPluginRepository {
if (ArrayUtils.isEmpty(selectedPluginKeys)) {
selectedPluginKeys = new String[]{AbstractCoverageExtension.DEFAULT_PLUGIN};
}
- return ArrayUtils.contains(selectedPluginKeys, pluginKey);
+ String oldCoveragePluginKey = getOldCoveragePluginKey(pluginKey);
+ return ArrayUtils.contains(selectedPluginKeys, pluginKey) || ArrayUtils.contains(selectedPluginKeys, oldCoveragePluginKey);
+ }
+
+ private String getOldCoveragePluginKey(String pluginKey) {
+ if (StringUtils.equals("sonar-jacoco-plugin", pluginKey)) {
+ return "jacoco";
+ }
+ if (StringUtils.equals("sonar-emma-plugin", pluginKey)) {
+ return "emma";
+ }
+ return null;
}
@Override
diff --git a/sonar-batch/src/test/java/org/sonar/batch/BatchPluginRepositoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/BatchPluginRepositoryTest.java
index 1f7696ea5d8..337d40f81e1 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/BatchPluginRepositoryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/BatchPluginRepositoryTest.java
@@ -65,6 +65,31 @@ public class BatchPluginRepositoryTest {
assertThat(repository.shouldRegisterCoverageExtension("other"), is(false));
}
+ @Test
+ public void shouldActivateOldVersionOfEmma() {
+ Configuration conf = new PropertiesConfiguration();
+ conf.setProperty(AbstractCoverageExtension.PARAM_PLUGIN, "emma");
+ BatchPluginRepository repository = new BatchPluginRepository(conf);
+
+ assertThat(repository.shouldRegisterCoverageExtension("sonar-emma-plugin"), is(true));
+ assertThat(repository.shouldRegisterCoverageExtension("emma"), is(true));
+
+ assertThat(repository.shouldRegisterCoverageExtension("sonar-jacoco-plugin"), is(false));
+ assertThat(repository.shouldRegisterCoverageExtension("jacoco"), is(false));
+ assertThat(repository.shouldRegisterCoverageExtension("clover"), is(false));
+ assertThat(repository.shouldRegisterCoverageExtension("cobertura"), is(false));
+ }
+
+ @Test
+ public void shouldActivateOldVersionOfJacoco() {
+ Configuration conf = new PropertiesConfiguration();
+ conf.setProperty(AbstractCoverageExtension.PARAM_PLUGIN, "cobertura,jacoco");
+ BatchPluginRepository repository = new BatchPluginRepository(conf);
+
+ assertThat(repository.shouldRegisterCoverageExtension("sonar-jacoco-plugin"), is(true));
+ assertThat(repository.shouldRegisterCoverageExtension("jacoco"), is(true));
+ assertThat(repository.shouldRegisterCoverageExtension("emma"), is(false));
+ }
public static class FakeBatchExtension implements BatchExtension {