aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2022-01-05 16:17:09 -0600
committersonartech <sonartech@sonarsource.com>2022-02-02 20:02:54 +0000
commita53007e8246c8d44b0c9af4bd3757313c48dd230 (patch)
treec53786ac80233b0296ee345e11d64bb762e5b463 /sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest
parente6afd7889c39e6b9db5e62ee5f850eae598ba62d (diff)
downloadsonarqube-a53007e8246c8d44b0c9af4bd3757313c48dd230.tar.gz
sonarqube-a53007e8246c8d44b0c9af4bd3757313c48dd230.zip
SONAR-15966 Use Spring instead of Pico as dependency injection framework in the scanner-engine
Co-authored-by: Zipeng WU <zipeng.wu@sonarsource.com>
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObserver.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObservers.java12
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisResult.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakePluginInstaller.java2
4 files changed, 11 insertions, 13 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObserver.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObserver.java
index 3fe40990f84..77fac1555cc 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObserver.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObserver.java
@@ -21,13 +21,13 @@ package org.sonar.scanner.mediumtest;
import org.sonar.api.ExtensionPoint;
import org.sonar.api.scanner.ScannerSide;
-import org.sonar.scanner.scan.ProjectScanContainer;
+import org.sonar.scanner.scan.SpringProjectScanContainer;
@ScannerSide
@ExtensionPoint
@FunctionalInterface
public interface AnalysisObserver {
- void analysisCompleted(ProjectScanContainer container);
+ void analysisCompleted(SpringProjectScanContainer container);
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObservers.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObservers.java
index 088c15e175b..9fe59b99499 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObservers.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisObservers.java
@@ -19,22 +19,18 @@
*/
package org.sonar.scanner.mediumtest;
-import org.sonar.scanner.scan.ProjectScanContainer;
+import org.sonar.scanner.scan.SpringProjectScanContainer;
public class AnalysisObservers {
- private AnalysisObserver[] observers;
- private ProjectScanContainer projectScanContainer;
+ private final AnalysisObserver[] observers;
+ private final SpringProjectScanContainer projectScanContainer;
- public AnalysisObservers(ProjectScanContainer projectScanContainer, AnalysisObserver... observers) {
+ public AnalysisObservers(SpringProjectScanContainer projectScanContainer, AnalysisObserver... observers) {
this.projectScanContainer = projectScanContainer;
this.observers = observers;
}
- public AnalysisObservers(ProjectScanContainer projectScanContainer) {
- this(projectScanContainer, new AnalysisObserver[0]);
- }
-
public void notifyEndOfScanTask() {
for (AnalysisObserver analysisObserver : observers) {
analysisObserver.analysisCompleted(projectScanContainer);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisResult.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisResult.java
index e9eaaf6c84b..1f002bf75bd 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisResult.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/AnalysisResult.java
@@ -43,7 +43,7 @@ import org.sonar.scanner.protocol.output.ScannerReport.Symbol;
import org.sonar.scanner.protocol.output.ScannerReportReader;
import org.sonar.scanner.report.ReportPublisher;
import org.sonar.scanner.report.ScannerReportUtils;
-import org.sonar.scanner.scan.ProjectScanContainer;
+import org.sonar.scanner.scan.SpringProjectScanContainer;
import org.sonar.scanner.scan.filesystem.InputComponentStore;
public class AnalysisResult implements AnalysisObserver {
@@ -55,7 +55,7 @@ public class AnalysisResult implements AnalysisObserver {
private ScannerReportReader reader;
@Override
- public void analysisCompleted(ProjectScanContainer container) {
+ public void analysisCompleted(SpringProjectScanContainer container) {
LOG.info("Store analysis results in memory for later assertions in medium test");
ReportPublisher reportPublisher = container.getComponentByType(ReportPublisher.class);
reader = new ScannerReportReader(reportPublisher.getReportDir().toFile());
@@ -69,7 +69,7 @@ public class AnalysisResult implements AnalysisObserver {
return reader;
}
- private void storeFs(ProjectScanContainer container) {
+ private void storeFs(SpringProjectScanContainer container) {
InputComponentStore inputFileCache = container.getComponentByType(InputComponentStore.class);
for (InputFile inputPath : inputFileCache.inputFiles()) {
inputFilesByKeys.put(((DefaultInputFile) inputPath).getProjectRelativePath(), inputPath);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakePluginInstaller.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakePluginInstaller.java
index ea08a9ae8d5..5800b912a7b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakePluginInstaller.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/FakePluginInstaller.java
@@ -24,11 +24,13 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.annotation.Priority;
import org.sonar.api.Plugin;
import org.sonar.core.platform.PluginInfo;
import org.sonar.scanner.bootstrap.PluginInstaller;
import org.sonar.scanner.bootstrap.ScannerPlugin;
+@Priority(1)
public class FakePluginInstaller implements PluginInstaller {
private final Map<String, ScannerPlugin> pluginsByKeys = new HashMap<>();