aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-07-27 22:57:19 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-07-27 22:57:19 +0200
commitb710ae53feba2a4d8d2c181a26d5d1163e407d1b (patch)
treeb6c485dd46d35115a0100dbe25d594a4dca8733d /sonar-scanner-engine
parente4ba85fe304aaad519e574b8f4e172b733389752 (diff)
parent85bfbe28689b4276a04eeeed91b205ab76e81d06 (diff)
downloadsonarqube-b710ae53feba2a4d8d2c181a26d5d1163e407d1b.tar.gz
sonarqube-b710ae53feba2a4d8d2c181a26d5d1163e407d1b.zip
Fix merge of branch-6.0
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java11
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java10
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java12
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java12
4 files changed, 19 insertions, 26 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
index 605a067c66f..cb98c42d047 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java
@@ -21,13 +21,14 @@ package org.sonar.scanner.bootstrap;
import java.util.List;
import java.util.Map;
-
import org.sonar.api.Plugin;
-import org.sonar.api.SonarProduct;
import org.sonar.api.SonarQubeSide;
-import org.sonar.api.internal.SonarRuntimeFactory;
+import org.sonar.api.SonarQubeVersion;
+import org.sonar.api.internal.ApiVersion;
+import org.sonar.api.internal.SonarRuntimeImpl;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.UriReader;
+import org.sonar.api.utils.Version;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.core.platform.ComponentContainer;
@@ -69,6 +70,7 @@ public class GlobalContainer extends ComponentContainer {
}
private void addBootstrapComponents() {
+ Version apiVersion = ApiVersion.load(System2.INSTANCE);
add(
// plugins
BatchPluginRepository.class,
@@ -78,7 +80,8 @@ public class GlobalContainer extends ComponentContainer {
BatchPluginPredicate.class,
ExtensionInstaller.class,
- SonarRuntimeFactory.create(System2.INSTANCE, SonarProduct.SONARQUBE, SonarQubeSide.SCANNER),
+ new SonarQubeVersion(apiVersion),
+ SonarRuntimeImpl.forSonarQube(apiVersion, SonarQubeSide.SCANNER),
CachesManager.class,
GlobalSettings.class,
new BatchWsClientProvider(),
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
index d3cb867c509..f19633527af 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
@@ -20,7 +20,6 @@
package org.sonar.scanner.sensor;
import java.io.Serializable;
-import org.sonar.api.SonarProduct;
import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.FileSystem;
@@ -100,13 +99,8 @@ public class DefaultSensorContext implements SensorContext {
}
@Override
- public Version getRuntimeApiVersion() {
- return sonarRuntime.getApiVersion();
- }
-
- @Override
- public SonarProduct getRuntimeProduct() {
- return sonarRuntime.getProduct();
+ public SonarRuntime runtime() {
+ return sonarRuntime;
}
@Override
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java
index 1ebd459f0eb..d278fcaeb81 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java
@@ -27,14 +27,10 @@ import org.junit.Test;
import org.sonar.api.BatchExtension;
import org.sonar.api.ExtensionProvider;
import org.sonar.api.SonarPlugin;
-import org.sonar.api.SonarQubeVersion;
+import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.core.platform.ComponentContainer;
import org.sonar.core.platform.PluginInfo;
-import org.sonar.scanner.bootstrap.BatchPluginRepository;
-import org.sonar.scanner.bootstrap.ExtensionInstaller;
-import org.sonar.scanner.bootstrap.ExtensionMatcher;
-import org.sonar.scanner.bootstrap.GlobalMode;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -64,7 +60,7 @@ public class ExtensionInstallerTest {
when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(Foo.class, Bar.class));
ComponentContainer container = new ComponentContainer();
- ExtensionInstaller installer = new ExtensionInstaller(mock(SonarQubeVersion.class), pluginRepository, mock(AnalysisMode.class));
+ ExtensionInstaller installer = new ExtensionInstaller(mock(SonarRuntime.class), pluginRepository, mock(AnalysisMode.class));
installer.install(container, new FooMatcher());
assertThat(container.getComponentByType(Foo.class)).isNotNull();
@@ -76,7 +72,7 @@ public class ExtensionInstallerTest {
when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo")));
when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(new FooProvider(), new BarProvider()));
ComponentContainer container = new ComponentContainer();
- ExtensionInstaller installer = new ExtensionInstaller(mock(SonarQubeVersion.class), pluginRepository, mock(AnalysisMode.class));
+ ExtensionInstaller installer = new ExtensionInstaller(mock(SonarRuntime.class), pluginRepository, mock(AnalysisMode.class));
installer.install(container, new FooMatcher());
@@ -89,7 +85,7 @@ public class ExtensionInstallerTest {
when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo")));
when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(new FooBarProvider()));
ComponentContainer container = new ComponentContainer();
- ExtensionInstaller installer = new ExtensionInstaller(mock(SonarQubeVersion.class), pluginRepository, mock(AnalysisMode.class));
+ ExtensionInstaller installer = new ExtensionInstaller(mock(SonarRuntime.class), pluginRepository, mock(AnalysisMode.class));
installer.install(container, new TrueMatcher());
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
index edcdaf576fb..a5eace1c537 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
@@ -24,9 +24,8 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
-import org.sonar.api.SonarProduct;
import org.sonar.api.SonarQubeSide;
-import org.sonar.api.SonarQubeVersion;
+import org.sonar.api.SonarRuntime;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.InputModule;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
@@ -35,6 +34,7 @@ import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
import org.sonar.api.batch.sensor.internal.SensorStorage;
import org.sonar.api.config.Settings;
+import org.sonar.api.internal.SonarRuntimeImpl;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.utils.Version;
@@ -56,7 +56,7 @@ public class DefaultSensorContextTest {
private Settings settings;
private SensorStorage sensorStorage;
private AnalysisMode analysisMode;
- private SonarQubeVersion sqVersion;
+ private SonarRuntime runtime;
@Before
public void prepare() throws Exception {
@@ -68,8 +68,8 @@ public class DefaultSensorContextTest {
settings = new Settings();
sensorStorage = mock(SensorStorage.class);
analysisMode = mock(AnalysisMode.class);
- sqVersion = new SonarQubeVersion(Version.parse("5.5"), SonarProduct.SONARQUBE, SonarQubeSide.SCANNER);
- adaptor = new DefaultSensorContext(mock(InputModule.class), settings, fs, activeRules, analysisMode, sensorStorage, sqVersion);
+ runtime = SonarRuntimeImpl.forSonarQube(Version.parse("5.5"), SonarQubeSide.SCANNER);
+ adaptor = new DefaultSensorContext(mock(InputModule.class), settings, fs, activeRules, analysisMode, sensorStorage, runtime);
}
@Test
@@ -78,7 +78,7 @@ public class DefaultSensorContextTest {
assertThat(adaptor.fileSystem()).isEqualTo(fs);
assertThat(adaptor.settings()).isEqualTo(settings);
assertThat(adaptor.getSonarQubeVersion()).isEqualTo(Version.parse("5.5"));
- assertThat(adaptor.getRuntimeProduct()).isEqualTo(SonarProduct.SONARQUBE);
+ assertThat(adaptor.runtime()).isEqualTo(runtime);
assertThat(adaptor.newIssue()).isNotNull();
assertThat(adaptor.newMeasure()).isNotNull();