diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2016-03-11 14:16:32 +0100 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2016-03-15 11:51:50 +0100 |
commit | bc1b7ed1c7a6db15710af9d68096d7e5d054c9f8 (patch) | |
tree | acc902c80fbbed6f826bfa8b29d621221086ea82 /sonar-batch | |
parent | f34cff29d700d04018b1fa89c4bf44e4c04c4342 (diff) | |
download | sonarqube-bc1b7ed1c7a6db15710af9d68096d7e5d054c9f8.tar.gz sonarqube-bc1b7ed1c7a6db15710af9d68096d7e5d054c9f8.zip |
SONAR-7153 Allow to override sonar.language with blank value
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/scan/LanguageVerifier.java | 6 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java | 12 |
2 files changed, 15 insertions, 3 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/LanguageVerifier.java b/sonar-batch/src/main/java/org/sonar/batch/scan/LanguageVerifier.java index 7ad6e9d339a..83e27324e64 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/LanguageVerifier.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/LanguageVerifier.java @@ -21,7 +21,7 @@ package org.sonar.batch.scan; import org.sonar.batch.repository.language.Language; import org.sonar.batch.repository.language.LanguagesRepository; - +import org.apache.commons.lang.StringUtils; import org.picocontainer.Startable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,8 +49,8 @@ public class LanguageVerifier implements Startable { @Override public void start() { - if (settings.hasKey(CoreProperties.PROJECT_LANGUAGE_PROPERTY)) { - String languageKey = settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY); + String languageKey = settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY); + if (StringUtils.isNotBlank(languageKey)) { LOG.info("Language is forced to {}", languageKey); Language language = languages.get(languageKey); if (language == null) { diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java index a45dad4445d..22a4f21091f 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java @@ -61,6 +61,18 @@ public class LanguageVerifierTest { verifier.stop(); } + + @Test + public void language_is_empty() { + settings.setProperty("sonar.language", ""); + LanguageVerifier verifier = new LanguageVerifier(settings, languages, fs); + verifier.start(); + + // no failure and no language is forced + assertThat(fs.languages()).isEmpty(); + + verifier.stop(); + } @Test public void language_is_valid() { |