aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-05-07 15:59:40 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-05-11 17:04:46 +0200
commit3c18d94e800d30e71b2ca578b2a4d606f824e844 (patch)
treeaca651a8adb71920ea839beb8975c425b94a587f /sonar-batch
parent079a8179040931d2589b7d9b233ca9ed949437e2 (diff)
downloadsonarqube-3c18d94e800d30e71b2ca578b2a4d606f824e844.tar.gz
sonarqube-3c18d94e800d30e71b2ca578b2a4d606f824e844.zip
SONAR-6535 API cleanup: deprecate BatchComponent and ServerComponent
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java56
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionMatcher.java3
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/MetricProvider.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java9
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java19
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrapper/EnvironmentInformation.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cpd/CpdEngine.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cpd/CpdMappings.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/debt/IssueChangelogDebtCalculator.java15
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingSettings.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDate.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDays.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysis.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousVersion.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersion.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/Caches.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/ResourceCache.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/ScanPersister.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/ignore/pattern/AbstractPatternInitializer.java9
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsRegexpScanner.java16
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/tracking/InitialOpenIssuesStack.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueHandlers.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueTracking.java11
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerIssueRepository.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerLineHashesLoader.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/ScanTaskObserver.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/PersistersExecutor.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/SensorMatcher.java45
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java11
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/platform/DefaultServer.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/qualitygate/GenerateQualityGateEvents.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGate.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/report/EventCache.java11
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/repository/language/LanguagesRepository.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/ModuleQProfiles.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java14
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/QProfileVerifier.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/DefaultSensorMatcher.java37
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java78
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java38
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java3
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java18
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputPathCache.java12
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactory.java8
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleInputFileCache.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetectionFactory.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureCache.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/Reporter.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/RuleNameProvider.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java9
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java11
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionUtilsTest.java41
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java4
85 files changed, 447 insertions, 354 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java
index fb55fdde0a4..c3bb030facc 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfigurator.java
@@ -23,7 +23,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.maven.project.MavenProject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.config.Settings;
@@ -44,7 +44,8 @@ import static org.sonar.api.utils.DateUtils.formatDateTime;
* Used by views !!
*
*/
-public class ProjectConfigurator implements BatchComponent {
+@BatchSide
+public class ProjectConfigurator {
private static final Logger LOG = LoggerFactory.getLogger(ProjectConfigurator.class);
private final System2 system2;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
index 6a19dc49ab7..cc9037a6ada 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
@@ -20,13 +20,36 @@
package org.sonar.batch.bootstrap;
import com.google.common.collect.Lists;
+import org.sonar.batch.components.TimeMachineConfiguration;
import org.sonar.batch.cpd.CpdComponents;
-import org.sonar.batch.design.*;
+import org.sonar.batch.debt.DebtDecorator;
+import org.sonar.batch.debt.IssueChangelogDebtCalculator;
+import org.sonar.batch.debt.NewDebtDecorator;
+import org.sonar.batch.debt.SqaleRatingDecorator;
+import org.sonar.batch.debt.SqaleRatingSettings;
+import org.sonar.batch.design.DirectoryDsmDecorator;
+import org.sonar.batch.design.DirectoryTangleIndexDecorator;
+import org.sonar.batch.design.FileTangleIndexDecorator;
+import org.sonar.batch.design.MavenDependenciesSensor;
+import org.sonar.batch.design.ProjectDsmDecorator;
+import org.sonar.batch.design.SubProjectDsmDecorator;
+import org.sonar.batch.issue.tracking.InitialOpenIssuesSensor;
+import org.sonar.batch.issue.tracking.IssueHandlers;
import org.sonar.batch.issue.tracking.IssueTracking;
+import org.sonar.batch.issue.tracking.IssueTrackingDecorator;
+import org.sonar.batch.language.LanguageDistributionDecorator;
import org.sonar.batch.maven.MavenProjectBootstrapper;
import org.sonar.batch.maven.MavenProjectBuilder;
import org.sonar.batch.maven.MavenProjectConverter;
-import org.sonar.batch.scan.report.*;
+import org.sonar.batch.qualitygate.GenerateQualityGateEvents;
+import org.sonar.batch.qualitygate.QualityGateVerifier;
+import org.sonar.batch.rule.QProfileEventsDecorator;
+import org.sonar.batch.scan.report.ConsoleReport;
+import org.sonar.batch.scan.report.HtmlReport;
+import org.sonar.batch.scan.report.IssuesReportBuilder;
+import org.sonar.batch.scan.report.JSONReport;
+import org.sonar.batch.scan.report.RuleNameProvider;
+import org.sonar.batch.scan.report.SourceProvider;
import org.sonar.batch.scm.ScmConfiguration;
import org.sonar.batch.scm.ScmSensor;
import org.sonar.batch.source.CodeColorizerSensor;
@@ -34,6 +57,7 @@ import org.sonar.batch.source.LinesSensor;
import org.sonar.core.computation.dbcleaner.DefaultPurgeTask;
import org.sonar.core.computation.dbcleaner.period.DefaultPeriodCleaner;
import org.sonar.core.config.CorePropertyDefinitions;
+import org.sonar.core.notification.DefaultNotificationManager;
import java.util.Collection;
import java.util.List;
@@ -75,7 +99,33 @@ public class BatchComponents {
// dbcleaner
DefaultPeriodCleaner.class,
- DefaultPurgeTask.class
+ DefaultPurgeTask.class,
+
+ QualityGateVerifier.class,
+
+ // language
+ LanguageDistributionDecorator.class,
+
+ // Debt
+ IssueChangelogDebtCalculator.class,
+ DebtDecorator.class,
+ NewDebtDecorator.class,
+ SqaleRatingDecorator.class,
+ SqaleRatingSettings.class,
+
+ DefaultNotificationManager.class,
+
+ // Quality Gate
+ GenerateQualityGateEvents.class,
+
+ // Issue tracking
+ IssueTrackingDecorator.class,
+ IssueHandlers.class,
+ InitialOpenIssuesSensor.class,
+
+ QProfileEventsDecorator.class,
+
+ TimeMachineConfiguration.class
);
components.addAll(CorePropertyDefinitions.all());
// CPD
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java
index 1575f757006..5a66504364e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java
@@ -23,7 +23,6 @@ import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import org.apache.commons.lang.ClassUtils;
-import org.sonar.api.BatchExtension;
import org.sonar.api.batch.CheckProject;
import org.sonar.api.batch.DependedUpon;
import org.sonar.api.batch.DependsUpon;
@@ -126,15 +125,15 @@ public class BatchExtensionDictionnary {
return result;
}
- protected List<Object> getExtensions(@Nullable Class type) {
+ protected List<Object> getExtensions(Class type) {
List<Object> extensions = Lists.newArrayList();
completeBatchExtensions(componentContainer, extensions, type);
return extensions;
}
- private static void completeBatchExtensions(ComponentContainer container, List<Object> extensions, @Nullable Class type) {
+ private static void completeBatchExtensions(ComponentContainer container, List<Object> extensions, Class type) {
if (container != null) {
- extensions.addAll(container.getComponentsByType(type != null ? type : BatchExtension.class));
+ extensions.addAll(container.getComponentsByType(type));
completeBatchExtensions(container.getParent(), extensions, type);
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java
index 856cf505642..59bf1498365 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DatabaseCompatibility.java
@@ -21,7 +21,7 @@ package org.sonar.batch.bootstrap;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseProperties;
@@ -32,7 +32,8 @@ import org.sonar.core.properties.PropertiesDao;
/**
* Detects if database is not up-to-date with the version required by the batch.
*/
-public class DatabaseCompatibility implements BatchComponent {
+@BatchSide
+public class DatabaseCompatibility {
private DatabaseVersion version;
private Settings settings;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionMatcher.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionMatcher.java
index 5a477d63bc1..530429fb986 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionMatcher.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionMatcher.java
@@ -19,9 +19,12 @@
*/
package org.sonar.batch.bootstrap;
+import org.sonar.api.BatchSide;
+
/**
* @since 3.6
*/
+@BatchSide
public interface ExtensionMatcher {
boolean accept(Object extension);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java
index 61bc80e6538..37519fdfb53 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ExtensionUtils.java
@@ -20,7 +20,7 @@
package org.sonar.batch.bootstrap;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.RequiresDB;
import org.sonar.api.batch.SupportedEnvironment;
@@ -41,8 +41,8 @@ public class ExtensionUtils {
return InstantiationStrategy.PER_PROJECT.equals(strategy);
}
- public static boolean isBatchExtension(Object extension) {
- return isType(extension, BatchExtension.class);
+ public static boolean isBatchSide(Object extension) {
+ return AnnotationUtils.getAnnotation(extension, BatchSide.class) != null;
}
public static boolean supportsEnvironment(Object extension, EnvironmentInformation environment) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
index 18be773ae8c..c5d2a431b8b 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/GlobalContainer.java
@@ -113,6 +113,7 @@ public class GlobalContainer extends ComponentContainer {
new FileCacheProvider(),
System2.INSTANCE,
DefaultI18n.class,
+ Durations.class,
new GlobalRepositoriesProvider(),
UserRepository.class);
addIfMissing(BatchPluginInstaller.class, PluginInstaller.class);
@@ -153,8 +154,7 @@ public class GlobalContainer extends ComponentContainer {
PastSnapshotFinderByPreviousAnalysis.class,
PastSnapshotFinderByVersion.class,
PastSnapshotFinderByPreviousVersion.class,
- PastSnapshotFinder.class,
- Durations.class);
+ PastSnapshotFinder.class);
}
@Override
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/MetricProvider.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/MetricProvider.java
index 35f9fb308f5..fd564925ef7 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/MetricProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/MetricProvider.java
@@ -20,7 +20,7 @@
package org.sonar.batch.bootstrap;
import com.google.common.collect.Lists;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.ExtensionProvider;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.measures.CoreMetrics;
@@ -29,8 +29,9 @@ import org.sonar.api.measures.Metrics;
import java.util.List;
+@BatchSide
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public class MetricProvider extends ExtensionProvider implements BatchComponent {
+public class MetricProvider extends ExtensionProvider {
private Metrics[] factories;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
index 91eac2e7ebe..4cb02122d92 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ServerClient.java
@@ -31,11 +31,11 @@ import com.google.gson.JsonParser;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
-import org.sonar.core.util.DefaultHttpDownloader;
-import org.sonar.batch.bootstrapper.EnvironmentInformation;
import org.sonar.api.utils.HttpDownloader;
+import org.sonar.batch.bootstrapper.EnvironmentInformation;
+import org.sonar.core.util.DefaultHttpDownloader;
import javax.annotation.Nullable;
@@ -54,7 +54,8 @@ import java.util.List;
*
* @since 3.4
*/
-public class ServerClient implements BatchComponent {
+@BatchSide
+public class ServerClient {
private static final String GET = "GET";
private BootstrapProperties props;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java
index fce09a6cd1c..e372178e2ba 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.bootstrap;
-import org.sonar.batch.components.PastMeasuresLoader;
-
import org.apache.commons.lang.StringUtils;
import org.sonar.api.CoreProperties;
import org.sonar.core.platform.ComponentContainer;
@@ -35,8 +33,6 @@ import org.sonar.batch.deprecated.tasks.Tasks;
import org.sonar.batch.scan.DeprecatedProjectReactorBuilder;
import org.sonar.batch.scan.ProjectReactorBuilder;
import org.sonar.batch.scan.ScanTask;
-import org.sonar.batch.scan.measure.DefaultMetricFinder;
-import org.sonar.batch.scan.measure.DeprecatedMetricFinder;
import org.sonar.core.permission.PermissionFacade;
import org.sonar.core.resource.DefaultResourcePermissions;
@@ -49,13 +45,11 @@ public class TaskContainer extends ComponentContainer {
private final Map<String, String> taskProperties;
private final Object[] components;
- private final DefaultAnalysisMode analysisMode;
public TaskContainer(ComponentContainer parent, Map<String, String> taskProperties, Object... components) {
super(parent);
this.taskProperties = taskProperties;
this.components = components;
- analysisMode = parent.getComponentByType(DefaultAnalysisMode.class);
}
@Override
@@ -63,24 +57,11 @@ public class TaskContainer extends ComponentContainer {
installCoreTasks();
installTaskExtensions();
installComponentsUsingTaskExtensions();
- addCoreComponents();
- if (analysisMode.isDb()) {
- addDataBaseComponents();
- }
for (Object component : components) {
add(component);
}
}
- private void addDataBaseComponents() {
- add(PastMeasuresLoader.class);
- }
-
- private void addCoreComponents() {
- add(DefaultMetricFinder.class,
- DeprecatedMetricFinder.class);
- }
-
void installCoreTasks() {
add(new TaskProperties(taskProperties, getParent().getComponentByType(BootstrapProperties.class).property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH)));
add(
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/EnvironmentInformation.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/EnvironmentInformation.java
index 7ce7c1f7cf1..c57d55a7c28 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/EnvironmentInformation.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/EnvironmentInformation.java
@@ -19,14 +19,15 @@
*/
package org.sonar.batch.bootstrapper;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
/**
* Describes execution environment.
*
* @since 2.6
*/
-public class EnvironmentInformation implements BatchComponent {
+@BatchSide
+public class EnvironmentInformation {
private String key;
private String version;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java
index d969e172338..672676edd36 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastMeasuresLoader.java
@@ -22,7 +22,7 @@ package org.sonar.batch.components;
import com.google.common.collect.Maps;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.measures.Metric;
@@ -41,7 +41,8 @@ import java.util.Map;
/**
* Can't be moved. Used by devcockpit.
*/
-public class PastMeasuresLoader implements BatchComponent {
+@BatchSide
+public class PastMeasuresLoader {
private Map<Integer, Metric> metricByIds;
private DatabaseSession session;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
index 745dcbf817b..f7d9f0bab2b 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
@@ -23,7 +23,7 @@ import com.google.common.base.Strings;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.database.model.Snapshot;
@@ -42,7 +42,8 @@ import java.util.Date;
/**
* Can't be moved since it is used by devcockpit.
*/
-public class PastSnapshotFinder implements BatchExtension {
+@BatchSide
+public class PastSnapshotFinder {
private static final Logger LOG = LoggerFactory.getLogger(PastSnapshotFinder.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java
index fa97f80d2eb..766bbab044e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java
@@ -21,7 +21,7 @@ package org.sonar.batch.components;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.RequiresDB;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
@@ -35,7 +35,8 @@ import static com.google.common.collect.Lists.newLinkedList;
import static org.sonar.api.utils.DateUtils.longToDate;
@RequiresDB
-public class TimeMachineConfiguration implements BatchComponent {
+@BatchSide
+public class TimeMachineConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(TimeMachineConfiguration.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdEngine.java b/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdEngine.java
index 45964262241..1fc4464c39c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdEngine.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdEngine.java
@@ -20,10 +20,11 @@
package org.sonar.batch.cpd;
import org.slf4j.Logger;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.sensor.SensorContext;
-public abstract class CpdEngine implements BatchExtension {
+@BatchSide
+public abstract class CpdEngine {
abstract boolean isLanguageSupported(String language);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdMappings.java b/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdMappings.java
index ff4b7a81beb..a4eae0c052d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdMappings.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cpd/CpdMappings.java
@@ -19,12 +19,13 @@
*/
package org.sonar.batch.cpd;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.CpdMapping;
import javax.annotation.CheckForNull;
-public class CpdMappings implements BatchComponent {
+@BatchSide
+public class CpdMappings {
private final CpdMapping[] mappings;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java b/sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java
index a11f94a0fde..77809c7f785 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cpd/index/IndexFactory.java
@@ -23,7 +23,7 @@ import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseSession;
@@ -34,7 +34,8 @@ import org.sonar.core.duplication.DuplicationDao;
import javax.annotation.Nullable;
-public class IndexFactory implements BatchComponent {
+@BatchSide
+public class IndexFactory {
private static final Logger LOG = LoggerFactory.getLogger(IndexFactory.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java
index f4521d664a6..3af2092c66e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java
@@ -26,6 +26,7 @@ import org.sonar.api.batch.DecoratorBarriers;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.batch.DependedUpon;
import org.sonar.api.batch.DependsUpon;
+import org.sonar.api.batch.RequiresDB;
import org.sonar.api.batch.rule.Rule;
import org.sonar.api.batch.rule.Rules;
import org.sonar.api.component.ResourcePerspectives;
@@ -61,6 +62,7 @@ import static com.google.common.collect.Maps.newHashMap;
* Decorator that computes the technical debt metric
*/
@DependsUpon(DecoratorBarriers.ISSUES_TRACKED)
+@RequiresDB
public final class DebtDecorator implements Decorator {
private final ResourcePerspectives perspectives;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/IssueChangelogDebtCalculator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/IssueChangelogDebtCalculator.java
index 7b925117ca1..dec9b442b55 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/debt/IssueChangelogDebtCalculator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/debt/IssueChangelogDebtCalculator.java
@@ -23,7 +23,7 @@ package org.sonar.batch.debt;
import com.google.common.base.Function;
import com.google.common.collect.Ordering;
import org.apache.commons.lang.time.DateUtils;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.api.issue.internal.FieldDiffs;
@@ -32,14 +32,21 @@ import org.sonar.core.issue.IssueUpdater;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import java.util.*;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import static com.google.common.collect.Lists.newArrayList;
/**
* Warning, before modifying this class, please do not forget that it's used by the Dev Cockpit plugin
*/
-public class IssueChangelogDebtCalculator implements BatchComponent {
+@BatchSide
+public class IssueChangelogDebtCalculator {
@CheckForNull
public Long calculateNewTechnicalDebt(Issue issue, @Nullable Date periodDate) {
@@ -55,7 +62,7 @@ public class IssueChangelogDebtCalculator implements BatchComponent {
@CheckForNull
private Long calculateNewTechnicalDebtValueFromChangelog(@Nullable Long currentTechnicalDebtValue, Issue issue, Date periodDate) {
List<FieldDiffs> changelog = technicalDebtHistory(issue);
- for (Iterator<FieldDiffs> iterator = changelog.iterator(); iterator.hasNext(); ) {
+ for (Iterator<FieldDiffs> iterator = changelog.iterator(); iterator.hasNext();) {
FieldDiffs diff = iterator.next();
Date date = diff.creationDate();
if (isLesserOrEqual(date, periodDate)) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java
index f437ffa3744..9909fc47476 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java
@@ -20,15 +20,13 @@
package org.sonar.batch.debt;
-import org.sonar.batch.components.Period;
-
-import org.sonar.batch.components.TimeMachineConfiguration;
import com.google.common.collect.ImmutableList;
import org.sonar.api.batch.Decorator;
import org.sonar.api.batch.DecoratorBarriers;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.batch.DependedUpon;
import org.sonar.api.batch.DependsUpon;
+import org.sonar.api.batch.RequiresDB;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.issue.Issuable;
import org.sonar.api.issue.Issue;
@@ -38,6 +36,8 @@ import org.sonar.api.measures.MeasureUtils;
import org.sonar.api.measures.Metric;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
+import org.sonar.batch.components.Period;
+import org.sonar.batch.components.TimeMachineConfiguration;
import javax.annotation.Nullable;
@@ -50,6 +50,7 @@ import static com.google.common.collect.Lists.newArrayList;
/**
* Decorator that computes the technical debt metric
*/
+@RequiresDB
@DependsUpon(DecoratorBarriers.ISSUES_TRACKED)
public final class NewDebtDecorator implements Decorator {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingSettings.java b/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingSettings.java
index f6cc8e660a6..23c5bbdd98e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingSettings.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingSettings.java
@@ -20,14 +20,15 @@
package org.sonar.batch.debt;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.measures.Metric;
import javax.annotation.Nullable;
-public class SqaleRatingSettings implements BatchComponent {
+@BatchSide
+public class SqaleRatingSettings {
private final Settings settings;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDate.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDate.java
index 5a5fff138a1..c4830c0d6ea 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDate.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDate.java
@@ -19,7 +19,7 @@
*/
package org.sonar.batch.deprecated.components;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
@@ -35,7 +35,8 @@ import java.util.List;
import static org.sonar.api.utils.DateUtils.dateToLong;
-public class PastSnapshotFinderByDate implements BatchExtension {
+@BatchSide
+public class PastSnapshotFinderByDate {
private DatabaseSession session;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDays.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDays.java
index 21ab5d15e13..7e54893d41d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDays.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByDays.java
@@ -20,7 +20,7 @@
package org.sonar.batch.deprecated.components;
import org.apache.commons.lang.time.DateUtils;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
@@ -28,10 +28,12 @@ import org.sonar.api.resources.Qualifiers;
import org.sonar.batch.components.PastSnapshot;
import javax.annotation.CheckForNull;
+
import java.util.Date;
import java.util.List;
-public class PastSnapshotFinderByDays implements BatchExtension {
+@BatchSide
+public class PastSnapshotFinderByDays {
private DatabaseSession session;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysis.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysis.java
index e770975d461..9f4a964b77f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysis.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousAnalysis.java
@@ -19,7 +19,7 @@
*/
package org.sonar.batch.deprecated.components;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
@@ -33,7 +33,8 @@ import java.util.List;
import static org.sonar.api.utils.DateUtils.longToDate;
-public class PastSnapshotFinderByPreviousAnalysis implements BatchExtension {
+@BatchSide
+public class PastSnapshotFinderByPreviousAnalysis {
private DatabaseSession session;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousVersion.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousVersion.java
index 2de291f3e04..b0a25385e62 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousVersion.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByPreviousVersion.java
@@ -19,7 +19,7 @@
*/
package org.sonar.batch.deprecated.components;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
@@ -30,7 +30,8 @@ import org.sonar.core.persistence.MyBatis;
import static org.sonar.api.utils.DateUtils.longToDate;
-public class PastSnapshotFinderByPreviousVersion implements BatchExtension {
+@BatchSide
+public class PastSnapshotFinderByPreviousVersion {
private final DatabaseSession session;
private final MyBatis mybatis;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersion.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersion.java
index c6f5423ffab..c7ae4158cba 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersion.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PastSnapshotFinderByVersion.java
@@ -19,20 +19,20 @@
*/
package org.sonar.batch.deprecated.components;
-import org.sonar.batch.components.PastSnapshot;
-
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
import org.sonar.api.resources.Qualifiers;
+import org.sonar.batch.components.PastSnapshot;
import java.util.Date;
import java.util.List;
import static org.sonar.api.utils.DateUtils.longToDate;
-public class PastSnapshotFinderByVersion implements BatchExtension {
+@BatchSide
+public class PastSnapshotFinderByVersion {
private final DatabaseSession session;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java
index 3cab5d098c8..55f9b810434 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java
@@ -20,7 +20,7 @@
package org.sonar.batch.deprecated.components;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.config.Settings;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.Snapshot;
@@ -30,12 +30,14 @@ import org.sonar.batch.components.PastSnapshot;
import org.sonar.batch.components.PastSnapshotFinder;
import javax.persistence.Query;
+
import java.util.List;
import static com.google.common.collect.Lists.newLinkedList;
import static org.sonar.api.utils.DateUtils.dateToLong;
-public class PeriodsDefinition implements BatchComponent {
+@BatchSide
+public class PeriodsDefinition {
private static final int NUMBER_OF_VARIATION_SNAPSHOTS = 5;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java b/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java
index e11322f8d10..78c07947429 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/duplication/DuplicationCache.java
@@ -21,7 +21,7 @@ package org.sonar.batch.duplication;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication;
import org.sonar.batch.index.Cache;
import org.sonar.batch.index.Caches;
@@ -29,7 +29,8 @@ import org.sonar.batch.index.Caches;
/**
* Cache of duplication blocks. This cache is shared amongst all project modules.
*/
-public class DuplicationCache implements BatchComponent {
+@BatchSide
+public class DuplicationCache {
private final Cache<DefaultDuplication> cache;
private int sequence = 1;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/Caches.java b/sonar-batch/src/main/java/org/sonar/batch/index/Caches.java
index ca2a33a5014..ac0f509ec9d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/Caches.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/Caches.java
@@ -32,7 +32,7 @@ import com.persistit.logging.Slf4jAdapter;
import org.apache.commons.io.FileUtils;
import org.picocontainer.Startable;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.utils.TempFolder;
import java.io.File;
@@ -44,7 +44,8 @@ import java.util.Set;
*
* @since 3.6
*/
-public class Caches implements BatchComponent, Startable {
+@BatchSide
+public class Caches implements Startable {
private final Set<String> cacheNames = Sets.newHashSet();
private File tempDir;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceCache.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceCache.java
index 12ca8d6be65..19de9fb7791 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceCache.java
@@ -23,7 +23,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.resources.Library;
@@ -37,7 +37,8 @@ import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Map;
-public class ResourceCache implements BatchComponent {
+@BatchSide
+public class ResourceCache {
// resource by component key
private final Map<String, BatchResource> resources = Maps.newLinkedHashMap();
// dedicated cache for libraries
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java
index 69b7dd98d85..33c2a98cc69 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceKeyMigration.java
@@ -23,7 +23,7 @@ import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
import org.sonar.api.database.DatabaseSession;
@@ -43,7 +43,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-public class ResourceKeyMigration implements BatchComponent {
+@BatchSide
+public class ResourceKeyMigration {
private static final String UNABLE_TO_UPDATE_COMPONENT_NO_MATCH_WAS_FOUND = "Unable to update component {}. No match was found.";
private static final String COMPONENT_CHANGED_TO = "Component {} changed to {}";
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ScanPersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/ScanPersister.java
index 2bd6532dd77..0dfd07a3061 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/ScanPersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/ScanPersister.java
@@ -19,9 +19,10 @@
*/
package org.sonar.batch.index;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
-public interface ScanPersister extends BatchComponent {
+@BatchSide
+public interface ScanPersister {
void persist();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java
index f0c1cfb1fbd..1023ab35c68 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueCache.java
@@ -19,7 +19,7 @@
*/
package org.sonar.batch.issue;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.batch.index.Cache;
import org.sonar.batch.index.Caches;
@@ -29,7 +29,8 @@ import java.util.Collection;
/**
* Shared issues among all project modules
*/
-public class IssueCache implements BatchComponent {
+@BatchSide
+public class IssueCache {
// component key -> issue key -> issue
private final Cache<DefaultIssue> cache;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java
index 469a65cb909..16b23a0f216 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java
@@ -19,11 +19,12 @@
*/
package org.sonar.batch.issue;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.issue.batch.IssueFilter;
import org.sonar.api.issue.internal.DefaultIssue;
-public class IssueFilters implements BatchComponent {
+@BatchSide
+public class IssueFilters {
private final org.sonar.api.issue.IssueFilter[] exclusionFilters;
private final IssueFilter[] filters;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/pattern/AbstractPatternInitializer.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/pattern/AbstractPatternInitializer.java
index e29fc5aaa30..e57ffe7d411 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/pattern/AbstractPatternInitializer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/pattern/AbstractPatternInitializer.java
@@ -22,14 +22,15 @@ package org.sonar.batch.issue.ignore.pattern;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.config.Settings;
import java.util.List;
import static com.google.common.base.Objects.firstNonNull;
-public abstract class AbstractPatternInitializer implements BatchExtension {
+@BatchSide
+public abstract class AbstractPatternInitializer {
private Settings settings;
@@ -53,7 +54,7 @@ public abstract class AbstractPatternInitializer implements BatchExtension {
}
public boolean hasMulticriteriaPatterns() {
- return ! multicriteriaPatterns.isEmpty();
+ return !multicriteriaPatterns.isEmpty();
}
public abstract void initializePatternsForPath(String relativePath, String componentKey);
@@ -68,7 +69,7 @@ public abstract class AbstractPatternInitializer implements BatchExtension {
String resourceKeyPattern = settings.getString(propPrefix + "resourceKey");
String ruleKeyPattern = settings.getString(propPrefix + "ruleKey");
String lineRange = "*";
- String[] fields = new String[] { resourceKeyPattern, ruleKeyPattern, lineRange };
+ String[] fields = new String[] {resourceKeyPattern, ruleKeyPattern, lineRange};
PatternDecoder.checkRegularLineConstraints(StringUtils.join(fields, ","), fields);
IssuePattern pattern = new IssuePattern(firstNonNull(resourceKeyPattern, "*"), firstNonNull(ruleKeyPattern, "*"));
PatternDecoder.decodeRangeOfLines(pattern, firstNonNull(lineRange, "*"));
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsRegexpScanner.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
index a86a5382cf7..792c4ba94cc 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
@@ -20,17 +20,16 @@
package org.sonar.batch.issue.ignore.scanner;
-import org.sonar.batch.issue.ignore.pattern.IssueExclusionPatternInitializer;
-import org.sonar.batch.issue.ignore.pattern.IssuePattern;
-import org.sonar.batch.issue.ignore.pattern.LineRange;
-
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
+import org.sonar.batch.issue.ignore.pattern.IssueExclusionPatternInitializer;
+import org.sonar.batch.issue.ignore.pattern.IssuePattern;
+import org.sonar.batch.issue.ignore.pattern.LineRange;
import java.io.File;
import java.io.IOException;
@@ -38,7 +37,8 @@ import java.nio.charset.Charset;
import java.util.List;
import java.util.Set;
-public class IssueExclusionsRegexpScanner implements BatchExtension {
+@BatchSide
+public class IssueExclusionsRegexpScanner {
private static final Logger LOG = LoggerFactory.getLogger(IssueExclusionsRegexpScanner.class);
@@ -64,8 +64,8 @@ public class IssueExclusionsRegexpScanner implements BatchExtension {
}
for (IssuePattern pattern : patternsInitializer.getBlockPatterns()) {
blockMatchers.add(new DoubleRegexpMatcher(
- java.util.regex.Pattern.compile(pattern.getBeginBlockRegexp()),
- java.util.regex.Pattern.compile(pattern.getEndBlockRegexp())));
+ java.util.regex.Pattern.compile(pattern.getBeginBlockRegexp()),
+ java.util.regex.Pattern.compile(pattern.getEndBlockRegexp())));
}
init();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/InitialOpenIssuesStack.java b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/InitialOpenIssuesStack.java
index 6d246b74606..8e73fb0a237 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/InitialOpenIssuesStack.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/InitialOpenIssuesStack.java
@@ -20,7 +20,7 @@
package org.sonar.batch.issue.tracking;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.batch.index.Cache;
import org.sonar.batch.index.Caches;
@@ -33,8 +33,9 @@ import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
+@BatchSide
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public class InitialOpenIssuesStack implements BatchExtension {
+public class InitialOpenIssuesStack {
private final Cache<IssueDto> issuesCache;
private final Cache<ArrayList<IssueChangeDto>> issuesChangelogCache;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueHandlers.java b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueHandlers.java
index b501e18ad66..f941bbcdcf8 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueHandlers.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueHandlers.java
@@ -19,7 +19,7 @@
*/
package org.sonar.batch.issue.tracking;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.IssueHandler;
import org.sonar.api.issue.internal.DefaultIssue;
@@ -30,7 +30,8 @@ import org.sonar.core.user.DefaultUser;
import javax.annotation.Nullable;
-public class IssueHandlers implements BatchComponent {
+@BatchSide
+public class IssueHandlers {
private final IssueHandler[] handlers;
private final DefaultContext context;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueTracking.java b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueTracking.java
index adbdbc97525..6d72febbb77 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueTracking.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueTracking.java
@@ -27,16 +27,21 @@ import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.issue.internal.DefaultIssue;
import javax.annotation.Nullable;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public class IssueTracking implements BatchComponent {
+@BatchSide
+public class IssueTracking {
/**
* @param sourceHashHolder Null when working on resource that is not a file (directory/project)
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java
index 0086ab704fa..ec1acefd4e1 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java
@@ -23,7 +23,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.rule.ActiveRule;
@@ -49,7 +49,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
-public class LocalIssueTracking implements BatchComponent {
+@BatchSide
+public class LocalIssueTracking {
private static final Logger LOG = LoggerFactory.getLogger(LocalIssueTracking.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerIssueRepository.java b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerIssueRepository.java
index 98719ce179b..7bfabac4a6e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerIssueRepository.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerIssueRepository.java
@@ -20,7 +20,7 @@
package org.sonar.batch.issue.tracking;
import com.google.common.base.Function;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.bootstrap.ProjectReactor;
@@ -45,7 +45,8 @@ import java.util.Collections;
import java.util.List;
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public class ServerIssueRepository implements BatchComponent {
+@BatchSide
+public class ServerIssueRepository {
private static final Logger LOG = Loggers.get(ServerIssueRepository.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerLineHashesLoader.java b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerLineHashesLoader.java
index 857bdb2fdaf..8f3be703e35 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerLineHashesLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerLineHashesLoader.java
@@ -19,9 +19,10 @@
*/
package org.sonar.batch.issue.tracking;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
-public interface ServerLineHashesLoader extends BatchComponent {
+@BatchSide
+public interface ServerLineHashesLoader {
String[] getLineHashes(String fileKey);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/ScanTaskObserver.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/ScanTaskObserver.java
index 196ac9a9250..78b886b51b9 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/ScanTaskObserver.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/ScanTaskObserver.java
@@ -19,10 +19,13 @@
*/
package org.sonar.batch.mediumtest;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
+import org.sonar.api.ExtensionPoint;
import org.sonar.batch.scan.ProjectScanContainer;
-public interface ScanTaskObserver extends BatchExtension {
+@BatchSide
+@ExtensionPoint
+public interface ScanTaskObserver {
void scanTaskCompleted(ProjectScanContainer container);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java
index 69bc2daad89..bf7dcb4731a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsExecutor.java
@@ -20,7 +20,7 @@
package org.sonar.batch.phases;
import com.google.common.collect.Lists;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.Decorator;
import org.sonar.api.batch.DecoratorContext;
@@ -41,7 +41,8 @@ import org.sonar.batch.sensor.coverage.CoverageExclusions;
import java.util.Collection;
import java.util.List;
-public class DecoratorsExecutor implements BatchComponent {
+@BatchSide
+public class DecoratorsExecutor {
private final DecoratorsSelector decoratorsSelector;
private final SonarIndex index;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PersistersExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PersistersExecutor.java
index 3618d96cedc..8483f14b71c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/PersistersExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PersistersExecutor.java
@@ -21,14 +21,15 @@ package org.sonar.batch.phases;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.events.EventBus;
import org.sonar.batch.index.ScanPersister;
import java.util.Arrays;
-public class PersistersExecutor implements BatchComponent {
+@BatchSide
+public class PersistersExecutor {
private static final Logger LOG = LoggerFactory.getLogger(PersistersExecutor.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java
index 9ef8f5d06f2..48297539fd1 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobsExecutor.java
@@ -23,7 +23,7 @@ import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.PostJob;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.resources.Project;
@@ -32,7 +32,8 @@ import org.sonar.batch.events.EventBus;
import java.util.Collection;
-public class PostJobsExecutor implements BatchComponent {
+@BatchSide
+public class PostJobsExecutor {
private static final Logger LOG = LoggerFactory.getLogger(PostJobsExecutor.class);
private final BatchExtensionDictionnary selector;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java b/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java
index 7194f548f02..43fec23ea3f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java
@@ -19,7 +19,7 @@
*/
package org.sonar.batch.phases;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Language;
@@ -30,7 +30,8 @@ import org.sonar.api.utils.SonarException;
/**
* Should be dropped when org.sonar.api.resources.Project is fully refactored.
*/
-public class ProjectInitializer implements BatchComponent {
+@BatchSide
+public class ProjectInitializer {
private Languages languages;
private Settings settings;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorMatcher.java b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorMatcher.java
deleted file mode 100644
index c098deb5f0f..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorMatcher.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.phases;
-
-import org.apache.commons.lang.ClassUtils;
-import org.sonar.api.BatchExtension;
-import org.sonar.api.batch.InstantiationStrategy;
-import org.sonar.api.batch.Sensor;
-import org.sonar.batch.bootstrap.ExtensionMatcher;
-
-/**
- * Allow to filter sensors that will be executed.
- * Used by views !!
- * @since 3.6
- *
- */
-@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public abstract class SensorMatcher implements BatchExtension, ExtensionMatcher {
-
- @Override
- public final boolean accept(Object extension) {
- return (ClassUtils.isAssignable(extension.getClass(), Sensor.class) && acceptSensor((Sensor) extension))
- || ClassUtils.isAssignable(extension.getClass(), org.sonar.api.batch.sensor.Sensor.class);
- }
-
- public abstract boolean acceptSensor(Sensor sensor);
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java
index 0c4b08160e3..a21b111c182 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsExecutor.java
@@ -20,7 +20,7 @@
package org.sonar.batch.phases;
import com.google.common.collect.Lists;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.resources.Project;
@@ -29,22 +29,21 @@ import org.sonar.batch.events.EventBus;
import java.util.Collection;
-public class SensorsExecutor implements BatchComponent {
+@BatchSide
+public class SensorsExecutor {
private EventBus eventBus;
private Project module;
private BatchExtensionDictionnary selector;
- private final SensorMatcher sensorMatcher;
- public SensorsExecutor(BatchExtensionDictionnary selector, Project project, EventBus eventBus, SensorMatcher sensorMatcher) {
+ public SensorsExecutor(BatchExtensionDictionnary selector, Project project, EventBus eventBus) {
this.selector = selector;
this.eventBus = eventBus;
this.module = project;
- this.sensorMatcher = sensorMatcher;
}
public void execute(SensorContext context) {
- Collection<Sensor> sensors = selector.select(Sensor.class, module, true, sensorMatcher);
+ Collection<Sensor> sensors = selector.select(Sensor.class, module, true, null);
eventBus.fireEvent(new SensorsPhaseEvent(Lists.newArrayList(sensors), true));
for (Sensor sensor : sensors) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/platform/DefaultServer.java b/sonar-batch/src/main/java/org/sonar/batch/platform/DefaultServer.java
index 662d5bd9a1e..3d19d4a12ce 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/platform/DefaultServer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/platform/DefaultServer.java
@@ -20,7 +20,7 @@
package org.sonar.batch.platform;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.Server;
@@ -33,7 +33,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
-public class DefaultServer extends Server implements BatchComponent {
+@BatchSide
+public class DefaultServer extends Server {
private Settings settings;
private ServerClient client;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java b/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java
index fa4f3ea613a..93362baf51d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java
@@ -21,12 +21,13 @@ package org.sonar.batch.postjob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor;
import org.sonar.api.config.Settings;
-public class PostJobOptimizer implements BatchComponent {
+@BatchSide
+public class PostJobOptimizer {
private static final Logger LOG = LoggerFactory.getLogger(PostJobOptimizer.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/GenerateQualityGateEvents.java b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/GenerateQualityGateEvents.java
index ee3f9f34a76..030571ce8d5 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/GenerateQualityGateEvents.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/GenerateQualityGateEvents.java
@@ -19,7 +19,12 @@
*/
package org.sonar.batch.qualitygate;
-import org.sonar.api.batch.*;
+import org.sonar.api.batch.Decorator;
+import org.sonar.api.batch.DecoratorContext;
+import org.sonar.api.batch.DependsUpon;
+import org.sonar.api.batch.RequiresDB;
+import org.sonar.api.batch.TimeMachine;
+import org.sonar.api.batch.TimeMachineQuery;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
@@ -34,6 +39,7 @@ import org.sonar.batch.report.EventCache;
import java.util.List;
+@RequiresDB
public class GenerateQualityGateEvents implements Decorator {
private final QualityGate qualityGate;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGate.java b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGate.java
index 2684f8d9cfa..644d5804807 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGate.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGate.java
@@ -21,13 +21,14 @@ package org.sonar.batch.qualitygate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import javax.annotation.Nullable;
import java.util.Collection;
-public class QualityGate implements BatchComponent {
+@BatchSide
+public class QualityGate {
private final String name;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/EventCache.java b/sonar-batch/src/main/java/org/sonar/batch/report/EventCache.java
index 387050f280e..d2936146d74 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/report/EventCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/report/EventCache.java
@@ -19,7 +19,7 @@
*/
package org.sonar.batch.report;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.resources.Resource;
import org.sonar.batch.index.ResourceCache;
import org.sonar.batch.protocol.Constants.EventCategory;
@@ -27,9 +27,14 @@ import org.sonar.batch.protocol.output.BatchReport.Event;
import javax.annotation.Nullable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
-public class EventCache implements BatchComponent {
+@BatchSide
+public class EventCache {
private final Map<Integer, List<Event>> eventsByComponentBatchId = new HashMap<>();
private final ResourceCache resourceCache;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java
index e062ccb1eac..be9bcbb49ad 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/report/ReportPublisher.java
@@ -25,7 +25,7 @@ import org.apache.commons.io.FileUtils;
import org.picocontainer.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.config.Settings;
@@ -41,7 +41,8 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-public class ReportPublisher implements BatchComponent, Startable {
+@BatchSide
+public class ReportPublisher implements Startable {
private static final Logger LOG = LoggerFactory.getLogger(ReportPublisher.class);
public static final String KEEP_REPORT_PROP_KEY = "sonar.batch.keepReport";
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/language/LanguagesRepository.java b/sonar-batch/src/main/java/org/sonar/batch/repository/language/LanguagesRepository.java
index dd80fee1dcd..6c815677651 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/repository/language/LanguagesRepository.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/repository/language/LanguagesRepository.java
@@ -19,7 +19,7 @@
*/
package org.sonar.batch.repository.language;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import javax.annotation.CheckForNull;
@@ -29,7 +29,8 @@ import java.util.Collection;
* Languages repository
* @since 4.4
*/
-public interface LanguagesRepository extends BatchComponent {
+@BatchSide
+public interface LanguagesRepository {
/**
* Get language.
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/ModuleQProfiles.java b/sonar-batch/src/main/java/org/sonar/batch/rule/ModuleQProfiles.java
index 9c0fe13d21e..65d166d2642 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/ModuleQProfiles.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/ModuleQProfiles.java
@@ -20,7 +20,7 @@
package org.sonar.batch.rule;
import com.google.common.collect.ImmutableMap;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.batch.protocol.input.ProjectRepositories;
import javax.annotation.CheckForNull;
@@ -31,7 +31,8 @@ import java.util.Map;
/**
* Lists the Quality profiles enabled on the current module.
*/
-public class ModuleQProfiles implements BatchComponent {
+@BatchSide
+public class ModuleQProfiles {
public static final String SONAR_PROFILE_PROP = "sonar.profile";
private final Map<String, QProfile> byLanguage;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java
index 4ebc91e489b..d879d976439 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java
@@ -21,11 +21,20 @@ package org.sonar.batch.rule;
import com.google.common.collect.ImmutableSortedMap;
import org.apache.commons.lang.time.DateUtils;
-import org.sonar.api.batch.*;
+import org.sonar.api.batch.Decorator;
+import org.sonar.api.batch.DecoratorContext;
+import org.sonar.api.batch.DependsUpon;
+import org.sonar.api.batch.RequiresDB;
+import org.sonar.api.batch.TimeMachine;
+import org.sonar.api.batch.TimeMachineQuery;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.*;
+import org.sonar.api.resources.Language;
+import org.sonar.api.resources.Languages;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Resource;
import org.sonar.api.utils.KeyValueFormat;
import org.sonar.batch.protocol.Constants.EventCategory;
import org.sonar.batch.report.EventCache;
@@ -37,6 +46,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
+@RequiresDB
public class QProfileEventsDecorator implements Decorator {
private final TimeMachine timeMachine;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileVerifier.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileVerifier.java
index 009b9d56253..a141502fd6c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileVerifier.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileVerifier.java
@@ -23,12 +23,13 @@ import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.config.Settings;
import org.sonar.api.utils.MessageException;
-public class QProfileVerifier implements BatchComponent {
+@BatchSide
+public class QProfileVerifier {
private static final Logger LOG = LoggerFactory.getLogger(QProfileVerifier.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/DefaultSensorMatcher.java b/sonar-batch/src/main/java/org/sonar/batch/scan/DefaultSensorMatcher.java
deleted file mode 100644
index 46cffb93ff7..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/DefaultSensorMatcher.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.scan;
-
-import org.sonar.api.batch.Sensor;
-import org.sonar.batch.phases.SensorMatcher;
-
-/**
- * By default all sensors are executed
- * @since 3.6
- *
- */
-public class DefaultSensorMatcher extends SensorMatcher {
-
- @Override
- public boolean acceptSensor(Sensor sensor) {
- return true;
- }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
index f8312429543..e3e808b914d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
@@ -21,7 +21,6 @@ package org.sonar.batch.scan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.internal.FileMetadata;
@@ -31,9 +30,11 @@ import org.sonar.core.platform.ComponentContainer;
import org.sonar.api.resources.Project;
import org.sonar.api.scan.filesystem.FileExclusions;
import org.sonar.batch.ProjectTree;
-import org.sonar.batch.bootstrap.*;
-import org.sonar.batch.components.TimeMachineConfiguration;
-import org.sonar.batch.debt.*;
+import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
+import org.sonar.batch.bootstrap.DefaultAnalysisMode;
+import org.sonar.batch.bootstrap.ExtensionInstaller;
+import org.sonar.batch.bootstrap.ExtensionMatcher;
+import org.sonar.batch.bootstrap.ExtensionUtils;
import org.sonar.batch.deprecated.DeprecatedSensorContext;
import org.sonar.batch.deprecated.ResourceFilters;
import org.sonar.batch.deprecated.components.DefaultProjectClasspath;
@@ -50,17 +51,34 @@ import org.sonar.batch.issue.ignore.pattern.IssueExclusionPatternInitializer;
import org.sonar.batch.issue.ignore.pattern.IssueInclusionPatternInitializer;
import org.sonar.batch.issue.ignore.scanner.IssueExclusionsLoader;
import org.sonar.batch.issue.ignore.scanner.IssueExclusionsRegexpScanner;
-import org.sonar.batch.issue.tracking.InitialOpenIssuesSensor;
-import org.sonar.batch.issue.tracking.IssueHandlers;
-import org.sonar.batch.issue.tracking.IssueTrackingDecorator;
-import org.sonar.batch.language.LanguageDistributionDecorator;
-import org.sonar.batch.phases.*;
+import org.sonar.batch.phases.DecoratorsExecutor;
+import org.sonar.batch.phases.InitializersExecutor;
+import org.sonar.batch.phases.PersistersExecutor;
+import org.sonar.batch.phases.PhaseExecutor;
+import org.sonar.batch.phases.PhasesTimeProfiler;
+import org.sonar.batch.phases.PostJobsExecutor;
+import org.sonar.batch.phases.ProjectInitializer;
+import org.sonar.batch.phases.SensorsExecutor;
import org.sonar.batch.postjob.DefaultPostJobContext;
import org.sonar.batch.postjob.PostJobOptimizer;
-import org.sonar.batch.qualitygate.GenerateQualityGateEvents;
-import org.sonar.batch.qualitygate.QualityGateVerifier;
-import org.sonar.batch.rule.*;
-import org.sonar.batch.scan.filesystem.*;
+import org.sonar.batch.rule.ModuleQProfiles;
+import org.sonar.batch.rule.QProfileDecorator;
+import org.sonar.batch.rule.QProfileSensor;
+import org.sonar.batch.rule.QProfileVerifier;
+import org.sonar.batch.rule.RuleFinderCompatibility;
+import org.sonar.batch.rule.RulesProfileProvider;
+import org.sonar.batch.scan.filesystem.ComponentIndexer;
+import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
+import org.sonar.batch.scan.filesystem.DeprecatedFileFilters;
+import org.sonar.batch.scan.filesystem.ExclusionFilters;
+import org.sonar.batch.scan.filesystem.FileIndexer;
+import org.sonar.batch.scan.filesystem.FileSystemLogger;
+import org.sonar.batch.scan.filesystem.InputFileBuilderFactory;
+import org.sonar.batch.scan.filesystem.LanguageDetectionFactory;
+import org.sonar.batch.scan.filesystem.ModuleFileSystemInitializer;
+import org.sonar.batch.scan.filesystem.ModuleInputFileCache;
+import org.sonar.batch.scan.filesystem.ProjectFileSystemAdapter;
+import org.sonar.batch.scan.filesystem.StatusDetectionFactory;
import org.sonar.batch.scan.report.IssuesReports;
import org.sonar.batch.sensor.DefaultSensorContext;
import org.sonar.batch.sensor.DefaultSensorStorage;
@@ -68,6 +86,7 @@ import org.sonar.batch.sensor.SensorOptimizer;
import org.sonar.batch.sensor.coverage.CoverageExclusions;
import org.sonar.batch.source.HighlightableBuilder;
import org.sonar.batch.source.SymbolizableBuilder;
+import org.sonar.core.timemachine.Periods;
public class ModuleScanContainer extends ComponentContainer {
private static final Logger LOG = LoggerFactory.getLogger(ModuleScanContainer.class);
@@ -84,9 +103,6 @@ public class ModuleScanContainer extends ComponentContainer {
protected void doBeforeStart() {
LOG.info("------------- Scan {}", module.getName());
addCoreComponents();
- if (analysisMode.isDb()) {
- addDataBaseComponents();
- }
addExtensions();
}
@@ -102,6 +118,7 @@ public class ModuleScanContainer extends ComponentContainer {
module.setSettings(moduleSettings);
add(
+ Periods.class,
PhaseExecutor.class,
RuleFinderCompatibility.class,
EventBus.class,
@@ -176,39 +193,12 @@ public class ModuleScanContainer extends ComponentContainer {
SymbolizableBuilder.class);
}
- private void addDataBaseComponents() {
- add(
- // Quality Gate
- QualityGateVerifier.class,
- GenerateQualityGateEvents.class,
-
- // language
- LanguageDistributionDecorator.class,
-
- // Debt
- IssueChangelogDebtCalculator.class,
- DebtDecorator.class,
- NewDebtDecorator.class,
- SqaleRatingDecorator.class,
- SqaleRatingSettings.class,
-
- // Issue tracking
- IssueTrackingDecorator.class,
- IssueHandlers.class,
- InitialOpenIssuesSensor.class,
-
- QProfileEventsDecorator.class,
-
- TimeMachineConfiguration.class);
-
- }
-
private void addExtensions() {
ExtensionInstaller installer = getComponentByType(ExtensionInstaller.class);
installer.install(this, new ExtensionMatcher() {
@Override
public boolean accept(Object extension) {
- if (ExtensionUtils.isType(extension, BatchComponent.class) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT)) {
+ if (ExtensionUtils.isBatchSide(extension) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT)) {
// Special use-case: the extension point ProjectBuilder is used in a Maven environment to define some
// new sub-projects without pom.
// Example : C# plugin adds sub-projects at runtime, even if they are not defined in root pom.
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
index 12a23bf62e4..4105dab49c1 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java
@@ -20,7 +20,6 @@
package org.sonar.batch.scan;
import com.google.common.annotations.VisibleForTesting;
-import org.sonar.api.BatchComponent;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.bootstrap.ProjectBootstrapper;
@@ -34,13 +33,22 @@ import org.sonar.api.utils.SonarException;
import org.sonar.batch.DefaultFileLinesContextFactory;
import org.sonar.batch.ProjectConfigurator;
import org.sonar.batch.ProjectTree;
-import org.sonar.batch.bootstrap.*;
+import org.sonar.batch.bootstrap.DefaultAnalysisMode;
+import org.sonar.batch.bootstrap.ExtensionInstaller;
+import org.sonar.batch.bootstrap.ExtensionMatcher;
+import org.sonar.batch.bootstrap.ExtensionUtils;
+import org.sonar.batch.bootstrap.MetricProvider;
+import org.sonar.batch.components.PastMeasuresLoader;
import org.sonar.batch.debt.DebtModelProvider;
-import org.sonar.batch.debt.IssueChangelogDebtCalculator;
import org.sonar.batch.deprecated.components.DefaultResourceCreationLock;
import org.sonar.batch.deprecated.components.PeriodsDefinition;
import org.sonar.batch.duplication.DuplicationCache;
-import org.sonar.batch.index.*;
+import org.sonar.batch.index.Caches;
+import org.sonar.batch.index.DefaultIndex;
+import org.sonar.batch.index.DependencyPersister;
+import org.sonar.batch.index.ResourceCache;
+import org.sonar.batch.index.ResourceKeyMigration;
+import org.sonar.batch.index.ResourcePersister;
import org.sonar.batch.issue.DefaultProjectIssues;
import org.sonar.batch.issue.IssueCache;
import org.sonar.batch.issue.tracking.InitialOpenIssuesStack;
@@ -50,19 +58,28 @@ import org.sonar.batch.mediumtest.ScanTaskObservers;
import org.sonar.batch.phases.GraphPersister;
import org.sonar.batch.profiling.PhasesSumUpTimeProfiler;
import org.sonar.batch.qualitygate.QualityGateProvider;
-import org.sonar.batch.report.*;
+import org.sonar.batch.report.ComponentsPublisher;
+import org.sonar.batch.report.CoveragePublisher;
+import org.sonar.batch.report.DuplicationsPublisher;
+import org.sonar.batch.report.EventCache;
+import org.sonar.batch.report.IssuesPublisher;
+import org.sonar.batch.report.MeasuresPublisher;
+import org.sonar.batch.report.ReportPublisher;
+import org.sonar.batch.report.SourcePublisher;
+import org.sonar.batch.report.TestExecutionAndCoveragePublisher;
import org.sonar.batch.repository.ProjectRepositoriesProvider;
import org.sonar.batch.repository.language.DefaultLanguagesRepository;
import org.sonar.batch.rule.ActiveRulesProvider;
import org.sonar.batch.rule.RulesProvider;
import org.sonar.batch.scan.filesystem.InputPathCache;
+import org.sonar.batch.scan.measure.DefaultMetricFinder;
+import org.sonar.batch.scan.measure.DeprecatedMetricFinder;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.batch.source.CodeColorizers;
import org.sonar.core.component.ScanGraph;
import org.sonar.core.issue.IssueUpdater;
import org.sonar.core.issue.workflow.FunctionExecutor;
import org.sonar.core.issue.workflow.IssueWorkflow;
-import org.sonar.core.notification.DefaultNotificationManager;
import org.sonar.core.technicaldebt.DefaultTechnicalDebtModel;
import org.sonar.core.test.TestPlanBuilder;
import org.sonar.core.test.TestPlanPerspectiveLoader;
@@ -121,7 +138,6 @@ public class ProjectScanContainer extends ComponentContainer {
new ProjectRepositoriesProvider(),
DefaultResourceCreationLock.class,
CodeColorizers.class,
- DefaultNotificationManager.class,
MetricProvider.class,
ProjectConfigurator.class,
DefaultIndex.class,
@@ -142,10 +158,13 @@ public class ProjectScanContainer extends ComponentContainer {
IssueWorkflow.class,
IssueCache.class,
DefaultProjectIssues.class,
- IssueChangelogDebtCalculator.class,
LocalIssueTracking.class,
ServerIssueRepository.class,
+ // metrics
+ DefaultMetricFinder.class,
+ DeprecatedMetricFinder.class,
+
// tests
TestPlanPerspectiveLoader.class,
TestablePerspectiveLoader.class,
@@ -192,6 +211,7 @@ public class ProjectScanContainer extends ComponentContainer {
private void addDataBaseComponents() {
add(
+ PastMeasuresLoader.class,
ResourcePersister.class,
ResourceKeyMigration.class,
GraphPersister.class,
@@ -240,7 +260,7 @@ public class ProjectScanContainer extends ComponentContainer {
static class BatchExtensionFilter implements ExtensionMatcher {
@Override
public boolean accept(Object extension) {
- return ExtensionUtils.isType(extension, BatchComponent.class)
+ return ExtensionUtils.isBatchSide(extension)
&& ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_BATCH);
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java
index bb3f0f8a021..f6d8a8b59ac 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java
@@ -50,8 +50,7 @@ public class ScanTask implements Task {
DefaultProjectTree.class,
ProjectExclusions.class,
ProjectReactorValidator.class,
- ProjectReactorReady.class,
- DefaultSensorMatcher.class);
+ ProjectReactorReady.class);
scanContainer.execute();
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
index a30037a1c00..b8b48ec47fa 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java
@@ -19,7 +19,7 @@
*/
package org.sonar.batch.scan.filesystem;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.SonarIndex;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.resources.File;
@@ -37,7 +37,8 @@ import javax.annotation.Nullable;
*
* @since 4.2
*/
-public class ComponentIndexer implements BatchComponent {
+@BatchSide
+public class ComponentIndexer {
private final Languages languages;
private final SonarIndex sonarIndex;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java
index 16441588ac9..be1c52e58c2 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ExclusionFilters.java
@@ -22,12 +22,13 @@ package org.sonar.batch.scan.filesystem;
import org.apache.commons.lang.ArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.PathPattern;
import org.sonar.api.scan.filesystem.FileExclusions;
-public class ExclusionFilters implements BatchComponent {
+@BatchSide
+public class ExclusionFilters {
private static final Logger LOG = LoggerFactory.getLogger(ExclusionFilters.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java
index fbc40556475..0e5dec4bbad 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndexer.java
@@ -25,7 +25,7 @@ import org.apache.commons.io.filefilter.HiddenFileFilter;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputFileFilter;
@@ -37,13 +37,23 @@ import org.sonar.batch.util.ProgressReport;
import java.io.File;
import java.nio.file.Path;
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
/**
* Index input files into {@link InputPathCache}.
*/
-public class FileIndexer implements BatchComponent {
+@BatchSide
+public class FileIndexer {
private static final Logger LOG = LoggerFactory.getLogger(FileIndexer.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java
index 20fb55af219..6f1ba9e306c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java
@@ -23,7 +23,7 @@ import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.scan.filesystem.PathResolver;
import java.io.File;
@@ -32,7 +32,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
-public class FileSystemLogger implements BatchComponent {
+@BatchSide
+public class FileSystemLogger {
private final DefaultModuleFileSystem fs;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java
index 74685bd7955..cdee734908e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactory.java
@@ -19,15 +19,15 @@
*/
package org.sonar.batch.scan.filesystem;
-import org.sonar.api.batch.fs.internal.FileMetadata;
-
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.batch.fs.internal.FileMetadata;
import org.sonar.api.config.Settings;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
-public class InputFileBuilderFactory implements BatchComponent {
+@BatchSide
+public class InputFileBuilderFactory {
private final String moduleKey;
private final PathResolver pathResolver;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputPathCache.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputPathCache.java
index 92423f3a25d..f2ee0374493 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputPathCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/InputPathCache.java
@@ -21,7 +21,7 @@ package org.sonar.batch.scan.filesystem;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputPath;
@@ -29,13 +29,19 @@ import org.sonar.batch.index.BatchResource;
import javax.annotation.CheckForNull;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
/**
* Cache of all files and dirs. This cache is shared amongst all project modules. Inclusion and
* exclusion patterns are already applied.
*/
-public class InputPathCache implements BatchComponent {
+@BatchSide
+public class InputPathCache {
private final Map<String, SortedMap<String, InputFile>> inputFileCache = new LinkedHashMap<>();
private final Map<String, SortedMap<String, InputDir>> inputDirCache = new LinkedHashMap<>();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactory.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactory.java
index c52118612c3..114dcf8543c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactory.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactory.java
@@ -19,12 +19,12 @@
*/
package org.sonar.batch.scan.filesystem;
-import org.sonar.batch.repository.language.LanguagesRepository;
-
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.config.Settings;
+import org.sonar.batch.repository.language.LanguagesRepository;
-public class LanguageDetectionFactory implements BatchComponent {
+@BatchSide
+public class LanguageDetectionFactory {
private final Settings settings;
private final LanguagesRepository languages;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java
index 3f25a94c6c7..fd98170dbb5 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializer.java
@@ -21,7 +21,7 @@ package org.sonar.batch.scan.filesystem;
import com.google.common.collect.Lists;
import org.apache.commons.io.FileUtils;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.TempFolder;
@@ -34,7 +34,8 @@ import java.util.List;
/**
* @since 3.5
*/
-public class ModuleFileSystemInitializer implements BatchComponent {
+@BatchSide
+public class ModuleFileSystemInitializer {
private File baseDir, workingDir, buildDir;
private List<File> sourceDirsOrFiles = Lists.newArrayList();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleInputFileCache.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleInputFileCache.java
index 17420fc2dc8..dd4044b1bbc 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleInputFileCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ModuleInputFileCache.java
@@ -19,13 +19,14 @@
*/
package org.sonar.batch.scan.filesystem;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
-public class ModuleInputFileCache extends DefaultFileSystem.Cache implements BatchComponent {
+@BatchSide
+public class ModuleInputFileCache extends DefaultFileSystem.Cache {
private final String moduleKey;
private final InputPathCache inputPathCache;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetectionFactory.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetectionFactory.java
index 7ec9b895461..99acd6313ed 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetectionFactory.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/StatusDetectionFactory.java
@@ -19,10 +19,11 @@
*/
package org.sonar.batch.scan.filesystem;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.batch.protocol.input.ProjectRepositories;
-public class StatusDetectionFactory implements BatchComponent {
+@BatchSide
+public class StatusDetectionFactory {
private final ProjectRepositories projectReferentials;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureCache.java b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureCache.java
index 5cf7ce73f75..290f2955d07 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureCache.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureCache.java
@@ -20,7 +20,7 @@
package org.sonar.batch.scan.measure;
import com.google.common.base.Preconditions;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.RuleMeasure;
@@ -34,7 +34,8 @@ import org.sonar.batch.index.Caches;
/**
* Cache of all measures. This cache is shared amongst all project modules.
*/
-public class MeasureCache implements BatchComponent {
+@BatchSide
+public class MeasureCache {
private final Cache<Measure> cache;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java
index 36af32c9c92..f98704634a1 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java
@@ -21,7 +21,7 @@ package org.sonar.batch.scan.report;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchExtension;
+import org.sonar.api.BatchSide;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.api.resources.Project;
@@ -37,7 +37,8 @@ import org.sonar.batch.scan.filesystem.InputPathCache;
import javax.annotation.CheckForNull;
-public class IssuesReportBuilder implements BatchExtension {
+@BatchSide
+public class IssuesReportBuilder {
private static final Logger LOG = LoggerFactory.getLogger(IssuesReportBuilder.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java
index 986ba12d7e6..50f2a0ddb6e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReports.java
@@ -19,10 +19,11 @@
*/
package org.sonar.batch.scan.report;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.batch.bootstrap.DefaultAnalysisMode;
-public class IssuesReports implements BatchComponent {
+@BatchSide
+public class IssuesReports {
private final DefaultAnalysisMode analysisMode;
private final Reporter[] reporters;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/Reporter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/Reporter.java
index f2c84e963f7..4e1f5ea8199 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/Reporter.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/Reporter.java
@@ -19,9 +19,10 @@
*/
package org.sonar.batch.scan.report;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
-public interface Reporter extends BatchComponent {
+@BatchSide
+public interface Reporter {
public void execute();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/RuleNameProvider.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/RuleNameProvider.java
index 6828fca449d..d7d50aafabe 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/RuleNameProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/RuleNameProvider.java
@@ -20,14 +20,15 @@
package org.sonar.batch.scan.report;
import org.apache.commons.lang.StringEscapeUtils;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
import javax.annotation.CheckForNull;
-public class RuleNameProvider implements BatchComponent {
+@BatchSide
+public class RuleNameProvider {
private RuleFinder ruleFinder;
public RuleNameProvider(RuleFinder ruleFinder) {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java b/sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java
index 264a7202386..1f913e2b63f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java
@@ -23,7 +23,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.batch.index.BatchResource;
@@ -34,7 +34,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-public class SourceProvider implements BatchComponent {
+@BatchSide
+public class SourceProvider {
private static final Logger LOG = LoggerFactory.getLogger(SourceProvider.class);
private final InputPathCache inputPathCache;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java
index ec96767341e..526316f16f2 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scm/ScmConfiguration.java
@@ -23,7 +23,11 @@ import com.google.common.base.Joiner;
import org.picocontainer.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.*;
+import org.sonar.api.BatchSide;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.bootstrap.ProjectReactor;
@@ -47,7 +51,8 @@ import java.util.Map;
)
})
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public final class ScmConfiguration implements BatchComponent, Startable {
+@BatchSide
+public final class ScmConfiguration implements Startable {
private static final Logger LOG = LoggerFactory.getLogger(ScmConfiguration.class);
public static final String FORCE_RELOAD_KEY = "sonar.scm.forceReloadAll";
diff --git a/sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java b/sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java
index dbc4eac19e1..74c1e305e25 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/sensor/SensorOptimizer.java
@@ -21,7 +21,7 @@ package org.sonar.batch.sensor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.FilePredicate;
import org.sonar.api.batch.fs.FileSystem;
@@ -29,7 +29,8 @@ import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
import org.sonar.api.config.Settings;
-public class SensorOptimizer implements BatchComponent {
+@BatchSide
+public class SensorOptimizer {
private static final Logger LOG = LoggerFactory.getLogger(SensorOptimizer.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java b/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java
index 7ed223e5199..c8eb840272f 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java
@@ -24,7 +24,7 @@ import org.apache.commons.io.input.BOMInputStream;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
import org.sonar.api.batch.sensor.highlighting.NewHighlighting;
import org.sonar.api.web.CodeColorizerFormat;
import org.sonar.colorizer.CodeColorizer;
@@ -32,7 +32,11 @@ import org.sonar.colorizer.Tokenizer;
import javax.annotation.CheckForNull;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;
@@ -41,7 +45,8 @@ import java.util.Map;
/**
* Central point for sonar-colorizer extensions
*/
-public class CodeColorizers implements BatchComponent {
+@BatchSide
+public class CodeColorizers {
private static final Logger LOG = LoggerFactory.getLogger(CodeColorizers.class);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionUtilsTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionUtilsTest.java
index 95138b2e904..9deaf93ac81 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionUtilsTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionUtilsTest.java
@@ -20,8 +20,9 @@
package org.sonar.batch.bootstrap;
import org.junit.Test;
-import org.sonar.api.BatchExtension;
-import org.sonar.api.ServerExtension;
+import org.sonar.api.BatchComponent;
+import org.sonar.api.BatchSide;
+import org.sonar.api.ServerSide;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.RequiresDB;
import org.sonar.api.batch.SupportedEnvironment;
@@ -52,12 +53,13 @@ public class ExtensionUtilsTest {
}
@Test
- public void testIsBatchExtension() {
- assertThat(ExtensionUtils.isBatchExtension(BatchService.class)).isTrue();
- assertThat(ExtensionUtils.isBatchExtension(new BatchService())).isTrue();
+ public void testIsBatchSide() {
+ assertThat(ExtensionUtils.isBatchSide(BatchService.class)).isTrue();
+ assertThat(ExtensionUtils.isBatchSide(new BatchService())).isTrue();
+ assertThat(ExtensionUtils.isBatchSide(DeprecatedBatchService.class)).isTrue();
- assertThat(ExtensionUtils.isBatchExtension(ServerService.class)).isFalse();
- assertThat(ExtensionUtils.isBatchExtension(new ServerService())).isFalse();
+ assertThat(ExtensionUtils.isBatchSide(ServerService.class)).isFalse();
+ assertThat(ExtensionUtils.isBatchSide(new ServerService())).isFalse();
}
@Test
@@ -87,36 +89,47 @@ public class ExtensionUtilsTest {
assertThat(ExtensionUtils.requiresDB(new PersistentService())).isTrue();
}
+ @BatchSide
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
- public static class BatchService implements BatchExtension {
+ public static class BatchService {
}
+ public static class DeprecatedBatchService implements BatchComponent {
+
+ }
+
+ @BatchSide
@InstantiationStrategy(InstantiationStrategy.PER_PROJECT)
- public static class ProjectService implements BatchExtension {
+ public static class ProjectService {
}
- public static class DefaultService implements BatchExtension {
+ @BatchSide
+ public static class DefaultService {
}
- public static class ServerService implements ServerExtension {
+ @ServerSide
+ public static class ServerService {
}
+ @BatchSide
@SupportedEnvironment("maven")
- public static class MavenService implements BatchExtension {
+ public static class MavenService {
}
+ @BatchSide
@SupportedEnvironment({"maven", "ant", "gradle"})
- public static class BuildToolService implements BatchExtension {
+ public static class BuildToolService {
}
+ @BatchSide
@RequiresDB
- public static class PersistentService implements BatchExtension {
+ public static class PersistentService {
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java
index 000c64140d0..2ac9bab0fff 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java
@@ -66,7 +66,7 @@ public class MeasuresMediumTest {
.newScanTask(new File(projectDir, "sonar-project.properties"))
.start();
- assertThat(result.allMeasures()).hasSize(58);
+ assertThat(result.allMeasures()).hasSize(79);
}
@Test
@@ -93,7 +93,7 @@ public class MeasuresMediumTest {
.build())
.start();
- assertThat(result.allMeasures()).hasSize(28);
+ assertThat(result.allMeasures()).hasSize(37);
assertThat(result.allMeasures()).contains(new DefaultMeasure<Integer>()
.forMetric(CoreMetrics.LINES)
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
index b4f7dc49ce3..7037ec35550 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
@@ -109,8 +109,8 @@ public class ProjectScanContainerTest {
assertThat(filter.accept(MyProjectExtension.class)).isFalse();
assertThat(filter.accept(new MyServerExtension())).isFalse();
assertThat(filter.accept(MyServerExtension.class)).isFalse();
- assertThat(filter.accept(new MyTaskExtension())).isFalse();
- assertThat(filter.accept(MyTaskExtension.class)).isFalse();
+ assertThat(filter.accept(new MyTaskExtension())).isTrue();
+ assertThat(filter.accept(MyTaskExtension.class)).isTrue();
}
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)