From 9d60e84debda53bddf96fc379dbb6677aea549f2 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 26 Feb 2014 17:30:15 +0100 Subject: [PATCH] SONAR-926 fix deprecated key of files --- .../sonar/batch/scan/filesystem/ComponentIndexer.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java index 4751c2f10f5..bf169d2b7d7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ComponentIndexer.java @@ -30,10 +30,7 @@ import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.config.Settings; -import org.sonar.api.resources.File; -import org.sonar.api.resources.Languages; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.Resource; +import org.sonar.api.resources.*; import org.sonar.api.utils.SonarException; import org.sonar.batch.index.ResourceKeyMigration; @@ -72,8 +69,12 @@ public class ComponentIndexer implements BatchComponent { pathFromSourceDir = inputFile.relativePath(); } Resource sonarFile = File.create(inputFile.relativePath(), pathFromSourceDir, languages.get(languageKey), unitTest); + if (Java.KEY.equals(languageKey)) { + sonarFile.setDeprecatedKey(JavaFile.fromRelativePath(pathFromSourceDir, false).getDeprecatedKey()); + } else { + sonarFile.setDeprecatedKey(pathFromSourceDir); + } if (sonarFile != null) { - sonarFile.setDeprecatedKey(((DefaultInputFile) inputFile).deprecatedKey()); sonarIndex.index(sonarFile); importSources(fs, shouldImportSource, inputFile, sonarFile); } -- 2.39.5