aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2022-05-30 18:50:42 +0200
committersonartech <sonartech@sonarsource.com>2022-05-31 20:02:50 +0000
commit9097b10693f9c4fe2c7bde4bccdbca151ebfa452 (patch)
tree10eb71dfd890e5725f4f085386812eeb65c53197 /sonar-scanner-engine/src
parentcdeca9bf6ccd0cb1a3b2d397efa8ace1ef4789c2 (diff)
downloadsonarqube-9097b10693f9c4fe2c7bde4bccdbca151ebfa452.tar.gz
sonarqube-9097b10693f9c4fe2c7bde4bccdbca151ebfa452.zip
SONAR-16232 Use plugin api version for SonarRuntime impl
- introduce internal SonarQubeVersion
Diffstat (limited to 'sonar-scanner-engine/src')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java9
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/platform/DefaultServer.java10
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java8
3 files changed, 12 insertions, 15 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java
index 4e85fc6c1cc..dca880238dc 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java
@@ -28,7 +28,6 @@ import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
import org.sonar.api.SonarEdition;
import org.sonar.api.SonarQubeSide;
-import org.sonar.api.SonarQubeVersion;
import org.sonar.api.internal.MetadataLoader;
import org.sonar.api.internal.SonarRuntimeImpl;
import org.sonar.api.utils.MessageException;
@@ -79,10 +78,11 @@ public class SpringGlobalContainer extends SpringComponentContainer {
}
private void addBootstrapComponents() {
- Version apiVersion = MetadataLoader.loadVersion(System2.INSTANCE);
+ Version apiVersion = MetadataLoader.loadApiVersion(System2.INSTANCE);
+ Version sqVersion = MetadataLoader.loadSQVersion(System2.INSTANCE);
SonarEdition edition = MetadataLoader.loadEdition(System2.INSTANCE);
DefaultAnalysisWarnings analysisWarnings = new DefaultAnalysisWarnings(System2.INSTANCE);
- LOG.debug("{} {}", edition.getLabel(), apiVersion);
+ LOG.debug("{} {}", edition.getLabel(), sqVersion);
add(
// plugins
ScannerPluginRepository.class,
@@ -90,7 +90,8 @@ public class SpringGlobalContainer extends SpringComponentContainer {
PluginClassloaderFactory.class,
ScannerPluginJarExploder.class,
ExtensionInstaller.class,
- new SonarQubeVersion(apiVersion),
+ new org.sonar.api.SonarQubeVersion(sqVersion),
+ new org.sonar.core.platform.SonarQubeVersion(sqVersion),
new GlobalServerSettingsProvider(),
new GlobalConfigurationProvider(),
new ScannerWsClientProvider(),
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/platform/DefaultServer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/platform/DefaultServer.java
index e3b871d37c8..2d22dc26888 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/platform/DefaultServer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/platform/DefaultServer.java
@@ -22,10 +22,10 @@ package org.sonar.scanner.platform;
import java.util.Date;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.CoreProperties;
-import org.sonar.api.SonarRuntime;
import org.sonar.api.config.Configuration;
import org.sonar.api.platform.Server;
import org.sonar.api.utils.DateUtils;
+import org.sonar.core.platform.SonarQubeVersion;
import org.sonar.scanner.bootstrap.DefaultScannerWsClient;
import static org.apache.commons.lang.StringUtils.trimToEmpty;
@@ -34,12 +34,12 @@ public class DefaultServer extends Server {
private final Configuration settings;
private final DefaultScannerWsClient client;
- private final SonarRuntime runtime;
+ private final SonarQubeVersion sonarQubeVersion;
- public DefaultServer(Configuration settings, DefaultScannerWsClient client, SonarRuntime runtime) {
+ public DefaultServer(Configuration settings, DefaultScannerWsClient client, SonarQubeVersion sonarQubeVersion) {
this.settings = settings;
this.client = client;
- this.runtime = runtime;
+ this.sonarQubeVersion = sonarQubeVersion;
}
@Override
@@ -49,7 +49,7 @@ public class DefaultServer extends Server {
@Override
public String getVersion() {
- return runtime.getApiVersion().toString();
+ return sonarQubeVersion.get().toString();
}
@Override
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java
index c8979538a88..ee676ebbc0e 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/platform/DefaultServerTest.java
@@ -21,12 +21,9 @@ package org.sonar.scanner.platform;
import org.junit.Test;
import org.sonar.api.CoreProperties;
-import org.sonar.api.SonarEdition;
-import org.sonar.api.SonarQubeSide;
import org.sonar.api.config.internal.MapSettings;
-import org.sonar.api.config.internal.Settings;
-import org.sonar.api.internal.SonarRuntimeImpl;
import org.sonar.api.utils.Version;
+import org.sonar.core.platform.SonarQubeVersion;
import org.sonar.scanner.bootstrap.DefaultScannerWsClient;
import static org.assertj.core.api.Assertions.assertThat;
@@ -43,8 +40,7 @@ public class DefaultServerTest {
DefaultScannerWsClient client = mock(DefaultScannerWsClient.class);
when(client.baseUrl()).thenReturn("http://foo.com");
- DefaultServer metadata = new DefaultServer((settings).asConfig(), client,
- SonarRuntimeImpl.forSonarQube(Version.parse("2.2"), SonarQubeSide.SCANNER, SonarEdition.COMMUNITY));
+ DefaultServer metadata = new DefaultServer((settings).asConfig(), client, new SonarQubeVersion(Version.parse("2.2")));
assertThat(metadata.getId()).isEqualTo("123");
assertThat(metadata.getVersion()).isEqualTo("2.2");