aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src
diff options
context:
space:
mode:
authorDimitris Kavvathas <dimitris.kavvathas@sonarsource.com>2024-01-05 15:35:33 +0100
committersonartech <sonartech@sonarsource.com>2024-01-05 20:02:36 +0000
commitef96f7b0518343fa48a1d74d2763cd3ed479ba70 (patch)
tree10c7dcd6c1e0e401a10c6e7121e4e48b2cee99a1 /sonar-scanner-engine/src
parentedc58f42e62c4404906842fcc43ea31ae4bb8bd7 (diff)
downloadsonarqube-ef96f7b0518343fa48a1d74d2763cd3ed479ba70.tar.gz
sonarqube-ef96f7b0518343fa48a1d74d2763cd3ed479ba70.zip
SONAR-21195 Convert exception to a warning when no language plugins are installed.
Diffstat (limited to 'sonar-scanner-engine/src')
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/NoLanguagesPluginsMediumIT.java23
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java2
2 files changed, 18 insertions, 7 deletions
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/NoLanguagesPluginsMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/NoLanguagesPluginsMediumIT.java
index d575c39d0e5..db2d45e5904 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/NoLanguagesPluginsMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/NoLanguagesPluginsMediumIT.java
@@ -22,12 +22,15 @@ package org.sonar.scanner.mediumtest.fs;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.scanner.mediumtest.ScannerMediumTester;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.assertThat;
public class NoLanguagesPluginsMediumIT {
@Rule
@@ -36,15 +39,23 @@ public class NoLanguagesPluginsMediumIT {
@Rule
public ScannerMediumTester tester = new ScannerMediumTester();
+ @Rule
+ public LogTester logger = new LogTester();
+
+ @Before
+ public void before() {
+ logger.clear();
+ }
+
@Test
public void testNoLanguagePluginsInstalled() throws Exception {
File projectDir = copyProject("test-resources/mediumtest/xoo/sample");
- assertThatThrownBy(() -> tester
- .newAnalysis(new File(projectDir, "sonar-project.properties"))
- .execute())
- .isInstanceOf(IllegalStateException.class)
- .hasMessage("No language plugins are installed.");
+ tester.
+ newAnalysis(new File(projectDir, "sonar-project.properties"))
+ .execute();
+
+ assertThat(logger.logs(Level.WARN)).contains("No language plugins are installed.");
}
private File copyProject(String path) throws Exception {
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 3382d6f25de..bef9b1fb632 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
@@ -149,7 +149,7 @@ public class SpringProjectScanContainer extends SpringComponentContainer {
ScanProperties properties = getComponentByType(ScanProperties.class);
if (getComponentByType(Languages.class).all().length == 0) {
- throw new IllegalStateException("No language plugins are installed.");
+ LOG.warn("No language plugins are installed.");
}
// Log detected languages and their profiles after FS is indexed and languages detected