aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-03-24 16:45:07 -0500
committersonartech <sonartech@sonarsource.com>2021-03-26 20:03:35 +0000
commitef177c83ca161cd032e76a253d2eba64426d08fa (patch)
treef3bf2f5fddc1ddf3e8e97ef8524b670f661730dc /sonar-scanner-engine
parent872d2d640efefc3716aba19845042a71915497eb (diff)
downloadsonarqube-ef177c83ca161cd032e76a253d2eba64426d08fa.tar.gz
sonarqube-ef177c83ca161cd032e76a253d2eba64426d08fa.zip
SONAR-14550 Show analysis warning when scanner uses Java < 118.8.0.42792
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java13
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java3
2 files changed, 9 insertions, 7 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 886afd69033..74f450538d8 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
@@ -31,6 +31,7 @@ import org.sonar.api.SonarQubeVersion;
import org.sonar.api.SonarRuntime;
import org.sonar.api.internal.MetadataLoader;
import org.sonar.api.internal.SonarRuntimeImpl;
+import org.sonar.api.notifications.AnalysisWarnings;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.UriReader;
@@ -40,13 +41,14 @@ import org.sonar.api.utils.log.Loggers;
import org.sonar.core.extension.CoreExtensionRepositoryImpl;
import org.sonar.core.extension.CoreExtensionsLoader;
import org.sonar.core.platform.ComponentContainer;
+import org.sonar.core.platform.PluginClassLoader;
import org.sonar.core.platform.PluginClassloaderFactory;
import org.sonar.core.platform.PluginInfo;
-import org.sonar.core.platform.PluginClassLoader;
import org.sonar.core.platform.PluginRepository;
import org.sonar.core.util.DefaultHttpDownloader;
import org.sonar.core.util.UuidFactoryImpl;
import org.sonar.scanner.extension.ScannerCoreExtensionsInstaller;
+import org.sonar.scanner.notifications.DefaultAnalysisWarnings;
import org.sonar.scanner.platform.DefaultServer;
import org.sonar.scanner.repository.DefaultMetricsRepositoryLoader;
import org.sonar.scanner.repository.DefaultNewCodePeriodLoader;
@@ -81,19 +83,21 @@ public class GlobalContainer extends ComponentContainer {
addBootstrapComponents();
}
- private static void checkJavaVersion() {
+ private static void checkJavaVersion(AnalysisWarnings analysisWarnings) {
try {
String.class.getMethod("isBlank");
} catch (NoSuchMethodException e) {
- LOG.warn("SonarScanner will require Java 11 to run starting in SonarQube 9.x");
+ LOG.warn("SonarScanner will require Java 11 to run, starting in SonarQube 9.x");
+ analysisWarnings.addUnique("SonarScanner will require Java 11 to run, starting in SonarQube 9.x. Please upgrade the version of Java that executes the scanner.");
}
}
private void addBootstrapComponents() {
Version apiVersion = MetadataLoader.loadVersion(System2.INSTANCE);
SonarEdition edition = MetadataLoader.loadEdition(System2.INSTANCE);
+ DefaultAnalysisWarnings analysisWarnings = new DefaultAnalysisWarnings(System2.INSTANCE);
if (edition != SonarEdition.SONARCLOUD) {
- checkJavaVersion();
+ checkJavaVersion(analysisWarnings);
}
LOG.debug("{} {}", edition.getLabel(), apiVersion);
add(
@@ -110,6 +114,7 @@ public class GlobalContainer extends ComponentContainer {
DefaultServer.class,
new GlobalTempFolderProvider(),
DefaultHttpDownloader.class,
+ analysisWarnings,
UriReader.class,
PluginFiles.class,
System2.INSTANCE,
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 300d15568d9..d6c494f76fb 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.issue.ignore.pattern.IssueExclusionPatternInitializer;
import org.sonar.scanner.issue.ignore.pattern.IssueInclusionPatternInitializer;
import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader;
import org.sonar.scanner.mediumtest.AnalysisObservers;
-import org.sonar.scanner.notifications.DefaultAnalysisWarnings;
import org.sonar.scanner.postjob.DefaultPostJobContext;
import org.sonar.scanner.postjob.PostJobOptimizer;
import org.sonar.scanner.postjob.PostJobsExecutor;
@@ -231,8 +230,6 @@ public class ProjectScanContainer extends ComponentContainer {
ContextPropertiesCache.class,
ContextPropertiesPublisher.class,
- DefaultAnalysisWarnings.class,
-
SensorStrategy.class,
MutableProjectSettings.class,