*/
package org.sonar.batch.bootstrap;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
import com.google.common.collect.Lists;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.ArrayUtils;
import org.sonar.api.BatchExtension;
import org.sonar.api.Plugin;
import org.sonar.api.batch.AbstractCoverageExtension;
+import org.sonar.api.batch.CoverageExtension;
import org.sonar.api.batch.SupportedEnvironment;
import org.sonar.api.platform.Environment;
import org.sonar.api.resources.Java;
import org.sonar.core.plugin.JpaPluginDao;
import org.sonar.core.plugin.JpaPluginFile;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-
public class BatchPluginRepository extends AbstractPluginRepository {
private static final Logger LOG = LoggerFactory.getLogger(BatchPluginRepository.class);
ok = false;
LOG.debug("The following extension is ignored: " + extension + " due to execution environment.");
}
- if (ok && isType(extension, AbstractCoverageExtension.class)) {
+ if (ok && isType(extension, CoverageExtension.class)) {
ok = shouldRegisterCoverageExtension(pluginKey, container.getComponent(Project.class), container.getComponent(Configuration.class));
if (!ok) {
LOG.debug("The following extension is ignored: " + extension + ". See the parameter " + AbstractCoverageExtension.PARAM_PLUGIN);
}
boolean shouldRegisterCoverageExtension(String pluginKey, Project project, Configuration conf) {
- boolean ok = true;
+ if (!project.getAnalysisType().isDynamic(true)) {
+ // not dynamic and not reuse reports
+ return false;
+ }
if (StringUtils.equals(project.getLanguageKey(), Java.KEY)) {
String[] selectedPluginKeys = conf.getStringArray(AbstractCoverageExtension.PARAM_PLUGIN);
if (ArrayUtils.isEmpty(selectedPluginKeys)) {
selectedPluginKeys = new String[] { AbstractCoverageExtension.DEFAULT_PLUGIN };
}
- ok = ArrayUtils.contains(selectedPluginKeys, pluginKey);
+ return ArrayUtils.contains(selectedPluginKeys, pluginKey);
}
- return ok;
+ return true;
}
}
import org.sonar.api.batch.AbstractCoverageExtension;
import org.sonar.api.resources.Java;
import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Project.AnalysisType;
import org.sonar.api.utils.IocContainer;
-import org.sonar.batch.bootstrap.BatchPluginRepository;
public class BatchPluginRepositoryTest {
}
private static Project newJavaProject() {
- return new Project("foo").setLanguageKey(Java.KEY);
+ return new Project("foo").setLanguageKey(Java.KEY).setAnalysisType(AnalysisType.DYNAMIC);
}
private static Project newGroovyProject() {
- return new Project("foo").setLanguageKey("grvy");
+ return new Project("foo").setLanguageKey("grvy").setAnalysisType(AnalysisType.DYNAMIC);
}
public static class FakeBatchExtension implements BatchExtension {
*/
package org.sonar.api.batch;
-import org.sonar.api.BatchExtension;
import org.sonar.api.Plugins;
import org.sonar.api.resources.Project;
* It is a pre-implementation for Sensors and Decorators
*
* @since 1.10
+ * @deprecated since 2.6 was superseded by interface {@link CoverageExtension}
*/
-public abstract class AbstractCoverageExtension implements BatchExtension {
+public abstract class AbstractCoverageExtension implements CoverageExtension {
/**
* The plugin key to retrieve the coverage engine to be used
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.batch;
+
+import org.sonar.api.BatchExtension;
+
+/**
+ * Marker for extension. Extension which implements this interface would be active, when:
+ * <ul>
+ * <li>corresponding coverage engine activated (see {@link AbstractCoverageExtension#PARAM_PLUGIN}) and language is Java</li>
+ * <li>type of analysis is dynamic or reuse reports</li>
+ * </ul>
+ *
+ * @since 2.6
+ * @TODO Ability to configure coverage engine per language - http://jira.codehaus.org/browse/SONAR-1803
+ */
+public interface CoverageExtension extends BatchExtension {
+
+}