aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2023-12-20 12:33:45 +0100
committersonartech <sonartech@sonarsource.com>2024-01-04 20:02:48 +0000
commitd89cd75c3bb2a69f4cf71f0cac55cf41d23a223f (patch)
tree854b3e0fe73a07b282dba5fe301e9ab2d3fdbcf5 /sonar-scanner-engine
parentcd59a269218256fbd43e3e1573d0319b4253e245 (diff)
downloadsonarqube-d89cd75c3bb2a69f4cf71f0cac55cf41d23a223f.tar.gz
sonarqube-d89cd75c3bb2a69f4cf71f0cac55cf41d23a223f.zip
SONAR-21195 Support ProjectBuilders for on-demand plugins
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java8
2 files changed, 13 insertions, 1 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java
index ef749af6c04..6003bfb90fb 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java
@@ -49,8 +49,12 @@ public class ProjectBuildersExecutor {
}
public void execute(ProjectReactor reactor) {
+ executeProjectBuilders(projectBuilders, reactor, "Execute project builders");
+ }
+
+ public void executeProjectBuilders(ProjectBuilder[] projectBuilders, ProjectReactor reactor, String profilerMessage) {
if (projectBuilders.length > 0) {
- Profiler profiler = Profiler.create(LOG).startInfo("Execute project builders");
+ Profiler profiler = Profiler.create(LOG).startInfo(profilerMessage);
ProjectBuilderContext context = new ProjectBuilderContext(reactor, globalConfig);
for (ProjectBuilder projectBuilder : projectBuilders) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java
index 97ed1019fdd..3382d6f25de 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java
@@ -25,6 +25,8 @@ import javax.annotation.Priority;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.Plugin;
+import org.sonar.api.batch.bootstrap.ProjectBuilder;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.measures.Metrics;
import org.sonar.api.resources.Languages;
@@ -135,6 +137,12 @@ public class SpringProjectScanContainer extends SpringComponentContainer {
protected void doAfterStart() {
getParentComponentByType(ScannerMetrics.class).addPluginMetrics(getComponentsByType(Metrics.class));
getComponentByType(ProjectLock.class).tryLock();
+
+ // NOTE: ProjectBuilders executed here will have any changes they make to the ProjectReactor discarded.
+ ProjectBuilder[] phase2ProjectBuilders = getComponentsByType(ProjectBuilder.class).toArray(new ProjectBuilder[0]);
+ getComponentByType(ProjectBuildersExecutor.class).executeProjectBuilders(phase2ProjectBuilders, getComponentByType(ProjectReactor.class),
+ "Executing phase 2 project builders");
+
getComponentByType(ProjectFileIndexer.class).index();
GlobalAnalysisMode analysisMode = getComponentByType(GlobalAnalysisMode.class);
InputModuleHierarchy tree = getComponentByType(InputModuleHierarchy.class);