From 91720513ee12439d09703cc8837c3f5d40668ef1 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Thu, 17 Mar 2016 13:47:05 +0100 Subject: [PATCH] SONAR-7273 API returns different paths in case of single-module and multi-module configurations --- .../sonar/batch/scan/ProjectReactorBuilder.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java index 59ee5a499aa..2d7e453cfaf 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java @@ -23,7 +23,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import java.io.File; -import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.MessageFormat; import java.util.Arrays; import java.util.HashMap; @@ -399,19 +400,14 @@ public class ProjectReactorBuilder { "' (base directory = " + baseDir.getAbsolutePath() + ")"); } } - } protected static File resolvePath(File baseDir, String path) { - File file = new File(path); - if (!file.isAbsolute()) { - try { - file = new File(baseDir, path).getCanonicalFile(); - } catch (IOException e) { - throw new IllegalStateException("Unable to resolve path \"" + path + "\"", e); - } + Path filePath = Paths.get(path); + if (!filePath.isAbsolute()) { + filePath = baseDir.toPath().resolve(path); } - return file; + return filePath.normalize().toFile(); } /** -- 2.39.5