]> source.dussan.org Git - sonarqube.git/commitdiff
fix execution of jacoco and emma plugins
authorsimonbrandhof <simon.brandhof@gmail.com>
Thu, 30 Sep 2010 08:26:35 +0000 (08:26 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Thu, 30 Sep 2010 08:26:35 +0000 (08:26 +0000)
sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java
sonar-batch/src/test/java/org/sonar/batch/BatchPluginRepositoryTest.java

index 51a2e095380bc91d2467f6190de117a0cded4c2f..6ee190fabece593a27e1d5465ec54aeb7c7bab25 100644 (file)
@@ -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
index 1f7696ea5d8c895d3c9a1cd2431c1e702e3522b9..337d40f81e1eab7f3b7ac1b6d4426fd6d8f6edd6 100644 (file)
@@ -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 {