summaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-10-10 17:52:49 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-10-10 17:53:05 +0200
commitb018541aec8e8d43b5c557a07d8ef445821d77f3 (patch)
treee226979fd9dc325427657222d96f5c899ecf084a /sonar-batch
parent7cc177f8e0868eadbd592d9f4f3d98283729a912 (diff)
downloadsonarqube-b018541aec8e8d43b5c557a07d8ef445821d77f3.tar.gz
sonarqube-b018541aec8e8d43b5c557a07d8ef445821d77f3.zip
Add org.sonar.api.utils.PathUtils
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java
index 0d2a4d415a8..091e8790413 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileIndex.java
@@ -34,6 +34,7 @@ import org.sonar.api.scan.filesystem.InputFileFilter;
import org.sonar.api.scan.filesystem.ModuleFileSystem;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.scan.filesystem.internal.DefaultInputFile;
+import org.sonar.api.utils.PathUtils;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -140,6 +141,7 @@ public class FileIndex implements BatchComponent {
private void indexFile(ModuleFileSystem fileSystem, Progress status, File sourceDir, File file, String type) {
String relativePath = pathResolver.relativePath(fileSystem.baseDir(), file);
if (!cache.containsFile(fileSystem.moduleKey(), relativePath)) {
+ // Not indexed yet
InputFile input = newInputFile(fileSystem, sourceDir, type, file, relativePath);
if (input != null && accept(input)) {
cache.put(fileSystem.moduleKey(), input);
@@ -157,14 +159,13 @@ public class FileIndex implements BatchComponent {
return null;
}
- try {
Map<String, String> attributes = Maps.newHashMap();
set(attributes, InputFile.ATTRIBUTE_EXTENSION, extension);
set(attributes, InputFile.ATTRIBUTE_TYPE, type);
set(attributes, InputFile.ATTRIBUTE_LANGUAGE, lang);
// paths
- set(attributes, InputFile.ATTRIBUTE_SOURCEDIR_PATH, FilenameUtils.normalize(sourceDir.getCanonicalPath(), true));
+ set(attributes, InputFile.ATTRIBUTE_SOURCEDIR_PATH, PathUtils.canonicalPath(file));
set(attributes, InputFile.ATTRIBUTE_SOURCE_RELATIVE_PATH, pathResolver.relativePath(sourceDir, file));
// hash + status
@@ -172,9 +173,7 @@ public class FileIndex implements BatchComponent {
return DefaultInputFile.create(file, baseRelativePath, attributes);
- } catch (Exception e) {
- throw new IllegalStateException("Fail to read file: " + file.getAbsolutePath(), e);
- }
+
}
private void initStatus(File file, Charset charset, String baseRelativePath, Map<String, String> attributes) {