From: Julien HENRY Date: Mon, 17 Feb 2014 21:29:33 +0000 (+0100) Subject: SONAR-926 Don't fail when no language on the module (for example aggragator module) X-Git-Tag: 4.2~102 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dc002a9d9b6d1f228463e7e9c7727fa283af1149;p=sonarqube.git SONAR-926 Don't fail when no language on the module (for example aggragator module) --- diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/ProfileLogger.java b/sonar-batch/src/main/java/org/sonar/batch/phases/ProfileLogger.java index 5ec98bc7245..ec939d8df28 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/ProfileLogger.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/ProfileLogger.java @@ -60,7 +60,7 @@ public class ProfileLogger implements BatchComponent { defaultNameUsed = true; } } - if (!defaultNameUsed) { + if (!defaultNameUsed && !languages.languages().isEmpty()) { throw new SonarException("sonar.profile was set to '" + defaultName + "' but didn't match any profile for any language. Please check your configuration."); } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/phases/ProfileLoggerTest.java b/sonar-batch/src/test/java/org/sonar/batch/phases/ProfileLoggerTest.java index eb2d4689c44..22ec32b6e22 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/phases/ProfileLoggerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/phases/ProfileLoggerTest.java @@ -33,6 +33,7 @@ import org.sonar.api.utils.SonarException; import org.sonar.batch.rule.ModuleQProfiles; import org.sonar.batch.rule.ModuleQProfiles.QProfile; +import java.util.Collections; import java.util.List; import static org.mockito.Mockito.mock; @@ -103,6 +104,17 @@ public class ProfileLoggerTest { } + @Test + public void should_not_fail_if_no_language_on_project() { + settings.setProperty("sonar.profile", "Unknow"); + when(languages.languages()).thenReturn(Collections.emptyList()); + + ProfileLogger profileLogger = new ProfileLogger(settings, languages, profiles); + + profileLogger.execute(); + + } + @Test public void should_not_fail_if_default_profile_used_at_least_once() { settings.setProperty("sonar.profile", "My Java profile");