aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2017-07-24 12:08:00 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2017-08-07 11:44:06 +0200
commit94f2c5e8e859ff49d7a68d50d13b5b4f402ef28e (patch)
treeb670814b5584686daf1c6a99807aea3b596491ca /sonar-scanner-engine
parent460f96aa6333c848b3b733d538b27459fee3999a (diff)
downloadsonarqube-94f2c5e8e859ff49d7a68d50d13b5b4f402ef28e.tar.gz
sonarqube-94f2c5e8e859ff49d7a68d50d13b5b4f402ef28e.zip
SONAR-9575 Allow to replace ProjectRepositoriesProvider core implementation
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesProvider.java12
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/task/ScanTask.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesProviderTest.java2
4 files changed, 11 insertions, 7 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesProvider.java
index fa52178accd..a39aaf7a30d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/ProjectRepositoriesProvider.java
@@ -32,18 +32,22 @@ public class ProjectRepositoriesProvider extends ProviderAdapter {
private ProjectRepositories project = null;
public ProjectRepositories provide(ProjectRepositoriesLoader loader, ProjectKey projectKey, DefaultAnalysisMode mode) {
+ return provideInternal(loader, projectKey, mode.isIssues());
+ }
+
+ protected ProjectRepositories provideInternal(ProjectRepositoriesLoader loader, ProjectKey projectKey, boolean isIssueMode) {
if (project == null) {
Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
- project = loader.load(projectKey.get(), mode.isIssues());
- checkProject(mode);
+ project = loader.load(projectKey.get(), isIssueMode);
+ checkProject(isIssueMode);
profiler.stopInfo();
}
return project;
}
- private void checkProject(DefaultAnalysisMode mode) {
- if (mode.isIssues()) {
+ private void checkProject(boolean isIssueMode) {
+ if (isIssueMode) {
if (!project.exists()) {
LOG.warn("Project doesn't exist on the server. All issues will be marked as 'new'.");
} else if (project.lastAnalysisDate() == null) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
index 29a2461a70b..4049d49014e 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
@@ -74,7 +74,6 @@ import org.sonar.scanner.repository.DefaultQualityProfileLoader;
import org.sonar.scanner.repository.DefaultServerIssuesLoader;
import org.sonar.scanner.repository.ProjectRepositories;
import org.sonar.scanner.repository.ProjectRepositoriesLoader;
-import org.sonar.scanner.repository.ProjectRepositoriesProvider;
import org.sonar.scanner.repository.QualityProfileLoader;
import org.sonar.scanner.repository.QualityProfileProvider;
import org.sonar.scanner.repository.ServerIssuesLoader;
@@ -136,7 +135,6 @@ public class ProjectScanContainer extends ComponentContainer {
DefaultIndex.class,
Storages.class,
new RulesProvider(),
- new ProjectRepositoriesProvider(),
// temp
new AnalysisTempFolderProvider(),
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/ScanTask.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/ScanTask.java
index 3e75a016033..56423077a51 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/ScanTask.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/ScanTask.java
@@ -25,6 +25,7 @@ import org.sonar.api.task.TaskDefinition;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.scanner.analysis.AnalysisProperties;
import org.sonar.scanner.analysis.DefaultAnalysisMode;
+import org.sonar.scanner.repository.ProjectRepositoriesProvider;
import org.sonar.scanner.scan.ProjectScanContainer;
public class ScanTask implements Task {
@@ -47,6 +48,7 @@ public class ScanTask implements Task {
AnalysisProperties props = new AnalysisProperties(taskProps.properties(), taskProps.property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH));
ProjectScanContainer scanContainer = new ProjectScanContainer(taskContainer, props);
scanContainer.add(DefaultAnalysisMode.class);
+ scanContainer.add(new ProjectRepositoriesProvider());
scanContainer.execute();
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesProviderTest.java
index 2db06e5ad68..5dddeab9a29 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ProjectRepositoriesProviderTest.java
@@ -78,7 +78,7 @@ public class ProjectRepositoriesProviderTest {
assertThat(repo.exists()).isEqualTo(true);
assertThat(repo.lastAnalysisDate()).isNotNull();
- verify(mode, times(2)).isIssues();
+ verify(mode, times(1)).isIssues();
verify(projectKey).get();
verify(loader).load(eq("key"), eq(false));
verifyNoMoreInteractions(loader, projectKey, mode);