Key | Description
---|----|---
`sonar.branch` **![](/images/cross.svg)Deprecated since SQ 6.7** | _The Developer Edition provides fuller-featured branch functionality._ Manage SCM branches. Two branches of the same project are considered to be different projects in SonarQube. As a consequence issues found in a project A in a branch B1 are not linked to issues found for this project A in a branch B2. There is no way to automatically resolve issues from B2 when they are resolved in B1 as again A-B1 & A-B2 are considered separated projects.
-`sonar.language` **![](/images/cross.svg)Deprecated since SQ 4.5** | Set the language of the source code to analyze. Browse the Plugin Library page to get the list of all available languages. If not set, a multi-language analysis will be triggered.
-`sonar.profile` **![](/images/cross.svg)Deprecated since SQ 4.5** | Override the profile to be used. This should be set on a per-language basis through the UI instead.
+`sonar.profile` **![](/images/cross.svg)Deprecated since SQ 4.5** | Override the profile to be used. This should be set on a per-langauge basis through the UI instead.
`sonar.links.scm_dev` **![](/images/cross.svg)Deprecated since SQ 7.1** | Developer connection. | `<scm><developerConnection>` for Maven projects
<!-- /sonarqube -->
*/
String LONG_LIVED_BRANCHES_REGEX = "sonar.branch.longLivedBranches.regex";
- /**
- * @deprecated since 4.2 projects are now multi-language
- */
- @Deprecated
- String PROJECT_LANGUAGE_PROPERTY = "sonar.language";
-
/* Exclusions */
String PROJECT_INCLUSIONS_PROPERTY = "sonar.inclusions";
String PROJECT_EXCLUSIONS_PROPERTY = "sonar.exclusions";
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo
exclusionCounter.increaseByPatternsCount();
return;
}
+
String language = langDetection.language(realAbsoluteFile, projectRelativePath);
- if (language == null && langDetection.getForcedLanguage() != null) {
- LOG.warn("File '{}' is ignored because it doesn't belong to the forced language '{}'", realAbsoluteFile.toAbsolutePath(), langDetection.getForcedLanguage());
- return;
- }
if (ignoreCommand != null && ignoreCommand.isIgnored(realAbsoluteFile)) {
LOG.debug("File '{}' is excluded by the scm ignore settings.", realAbsoluteFile);
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.api.CoreProperties;
import org.sonar.api.batch.fs.internal.PathPattern;
import org.sonar.api.config.Configuration;
import org.sonar.api.utils.MessageException;
*/
private final Map<String, PathPattern[]> patternsByLanguage;
private final List<String> languagesToConsider;
- private final String forcedLanguage;
public LanguageDetection(Configuration settings, LanguagesRepository languages) {
Map<String, PathPattern[]> patternsByLanguageBuilder = new LinkedHashMap<>();
}
}
- forcedLanguage = StringUtils.defaultIfBlank(settings.get(CoreProperties.PROJECT_LANGUAGE_PROPERTY).orElse(null), null);
- // First try with lang patterns
- if (forcedLanguage != null) {
- if (!patternsByLanguageBuilder.containsKey(forcedLanguage)) {
- throw MessageException.of("You must install a plugin that supports the language '" + forcedLanguage + "'");
- }
- LOG.info("Language is forced to {}", forcedLanguage);
- languagesToConsider = Collections.singletonList(forcedLanguage);
- } else {
- languagesToConsider = Collections.unmodifiableList(new ArrayList<>(patternsByLanguageBuilder.keySet()));
- }
-
+ languagesToConsider = Collections.unmodifiableList(new ArrayList<>(patternsByLanguageBuilder.keySet()));
patternsByLanguage = Collections.unmodifiableMap(patternsByLanguageBuilder);
}
- public String getForcedLanguage() {
- return forcedLanguage;
- }
-
- Map<String, PathPattern[]> patternsByLanguage() {
- return patternsByLanguage;
- }
-
@CheckForNull
String language(Path absolutePath, Path relativePath) {
String detectedLanguage = null;
}
}
}
- if (detectedLanguage != null) {
- return detectedLanguage;
- }
- // Check if deprecated sonar.language is used and we are on a language without declared extensions.
- // Languages without declared suffixes match everything.
- if (forcedLanguage != null && patternsByLanguage.get(forcedLanguage).length == 0) {
- return forcedLanguage;
- }
- return null;
+ return detectedLanguage;
}
private boolean isCandidateForLanguage(Path absolutePath, Path relativePath, String languageKey) {
File projectDir = new File("test-resources/mediumtest/xoo/sample-with-symlink");
AnalysisResult result = tester
.newAnalysis(new File(projectDir, "sonar-project.properties"))
+ .property("sonar.exclusions", "**/*.xoo.measures,**/*.xoo.scm")
+ .property("sonar.test.exclusions", "**/*.xoo.measures,**/*.xoo.scm")
.execute();
assertThat(result.inputFiles()).hasSize(3);
File projectDir = new File("test-resources/mediumtest/xoo/sample-with-ignored-file");
AnalysisResult result = tester
.newAnalysis(new File(projectDir, "sonar-project.properties"))
+ .property("sonar.exclusions", "**/*.xoo.ignore")
+ .property("sonar.test.exclusions", "**/*.xoo.ignore")
.execute();
- assertThat(result.inputFiles()).hasSize(2);
assertThat(result.inputFile("xources/hello/ClassTwo.xoo")).isNull();
assertThat(result.inputFile("testx/ClassTwoTest.xoo")).isNull();
AnalysisResult result = tester
.newAnalysis(new File(projectDir, "sonar-project.properties"))
.property("sonar.scm.exclusions.disabled", "true")
+ .property("sonar.exclusions", "**/*.xoo.ignore")
+ .property("sonar.test.exclusions", "**/*.xoo.ignore")
.execute();
assertThat(result.inputFiles()).hasSize(4);
assertThat(detectLanguage(detection, "abc.abap")).isEqualTo("abap");
}
- @Test
- public void language_with_no_extension() throws Exception {
- // abap does not declare any file extensions.
- // When analyzing an ABAP project, then all source files must be parsed.
- LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("abap")));
-
- // No side-effect on non-ABAP projects
- LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
- assertThat(detectLanguage(detection, "abc")).isNull();
- assertThat(detectLanguage(detection, "abc.abap")).isNull();
- assertThat(detectLanguage(detection, "abc.java")).isEqualTo("java");
-
- settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "abap");
- detection = new LanguageDetection(settings.asConfig(), languages);
- assertThat(detectLanguage(detection, "abc")).isEqualTo("abap");
- assertThat(detectLanguage(detection, "abc.txt")).isEqualTo("abap");
- assertThat(detectLanguage(detection, "abc.java")).isEqualTo("abap");
- }
-
- @Test
- public void force_language_using_deprecated_property() throws Exception {
- LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
-
- settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "java");
- LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
- assertThat(detectLanguage(detection, "abc")).isNull();
- assertThat(detectLanguage(detection, "abc.php")).isNull();
- assertThat(detectLanguage(detection, "abc.java")).isEqualTo("java");
- assertThat(detectLanguage(detection, "src/abc.java")).isEqualTo("java");
- }
-
- @Test
- public void fail_if_invalid_language() {
- thrown.expect(MessageException.class);
- thrown.expectMessage("You must install a plugin that supports the language 'unknown'");
-
- LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("java", "java"), new MockLanguage("php", "php")));
- settings.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "unknown");
- new LanguageDetection(settings.asConfig(), languages);
- }
-
@Test
public void fail_if_conflicting_language_suffix() throws Exception {
LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
sonar.modules=java-module,groovy-module
-java-module.sonar.language=java
java-module.sonar.projectBaseDir=.
java-module.sonar.sources=src/main/java
-groovy-module.sonar.language=groovy
groovy-module.sonar.projectBaseDir=.
groovy-module.sonar.sources=src/main/groovy
sonar.projectName=Sonar :: Integration Tests :: Multi-modules Sample
sonar.projectVersion=1.0-SNAPSHOT
-sonar.language=xoo
-
# Some properties that will be inherited by the modules
sonar.sources=src/main/xoo
sonar.projectKey=sample-generic-coverage
sonar.sources=xources
-sonar.language=xoo
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo
sonar.projectName=Sample With Empty
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
-sonar.language=xoo
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo
sonar.scm.provider=xoo
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo
sonar.projectVersion=0.1-SNAPSHOT
sonar.sources=xources
sonar.tests=testx
-sonar.language=xoo