diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-01-09 10:22:37 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-01-09 10:26:08 +0100 |
commit | 5b86ca8831a8d2dba5460bb2732900dfd45feb66 (patch) | |
tree | 5492c4950858d126e3e2e751a169b751c4db5246 /sonar-batch | |
parent | 289558d892ca139cdb6da26f0349bafe54434bd8 (diff) | |
download | sonarqube-5b86ca8831a8d2dba5460bb2732900dfd45feb66.tar.gz sonarqube-5b86ca8831a8d2dba5460bb2732900dfd45feb66.zip |
SONAR-3024 Fix FileIndexer to set UTS qualifier on non Java tests
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/phases/FileIndexer.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/FileIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/phases/FileIndexer.java index ebcf828930e..dc1e8eda2a7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/FileIndexer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/FileIndexer.java @@ -22,10 +22,12 @@ package org.sonar.batch.phases; import org.sonar.api.BatchComponent; import org.sonar.api.batch.InstantiationStrategy; import org.sonar.api.batch.SensorContext; +import org.sonar.api.resources.File; import org.sonar.api.resources.Java; import org.sonar.api.resources.JavaFile; import org.sonar.api.resources.Languages; import org.sonar.api.resources.Project; +import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Resource; import org.sonar.api.scan.filesystem.FileQuery; import org.sonar.api.scan.filesystem.internal.InputFile; @@ -61,8 +63,11 @@ public class FileIndexer implements BatchComponent { if (Java.KEY.equals(languageKey)) { sonarFile = JavaFile.fromRelativePath(inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH), unitTest); } else { - sonarFile = new org.sonar.api.resources.File(languages.get(languageKey), - inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH)); + File newFile = new File(languages.get(languageKey), inputFile.attribute(InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH)); + if (newFile != null && unitTest) { + newFile.setQualifier(Qualifiers.UNIT_TEST_FILE); + } + sonarFile = newFile; } if (sonarFile != null) { sonarFile.setPath(inputFile.path()); |