diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-10-10 17:52:49 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-10-10 17:53:05 +0200 |
commit | b018541aec8e8d43b5c557a07d8ef445821d77f3 (patch) | |
tree | e226979fd9dc325427657222d96f5c899ecf084a /plugins/sonar-maven-batch-plugin | |
parent | 7cc177f8e0868eadbd592d9f4f3d98283729a912 (diff) | |
download | sonarqube-b018541aec8e8d43b5c557a07d8ef445821d77f3.tar.gz sonarqube-b018541aec8e8d43b5c557a07d8ef445821d77f3.zip |
Add org.sonar.api.utils.PathUtils
Diffstat (limited to 'plugins/sonar-maven-batch-plugin')
-rw-r--r-- | plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/MavenProjectConverter.java | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/MavenProjectConverter.java b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/MavenProjectConverter.java index 6b883439371..8dbd950b13b 100644 --- a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/MavenProjectConverter.java +++ b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/MavenProjectConverter.java @@ -33,12 +33,12 @@ import org.sonar.api.CoreProperties; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.maven.MavenUtils; import org.sonar.api.task.TaskExtension; +import org.sonar.api.utils.PathUtils; import org.sonar.api.utils.SonarException; import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; import org.sonar.java.api.JavaUtils; import javax.annotation.Nullable; - import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -55,13 +55,8 @@ public class MavenProjectConverter implements TaskExtension { Map<String, MavenProject> paths = Maps.newHashMap(); Map<MavenProject, ProjectDefinition> defs = Maps.newHashMap(); - try { - configureModules(poms, paths, defs); - - rebuildModuleHierarchy(paths, defs); - } catch (IOException e) { - throw new SonarException("Cannot configure project", e); - } + configureModules(poms, paths, defs); + rebuildModuleHierarchy(paths, defs); ProjectDefinition rootProject = defs.get(root); if (rootProject == null) { @@ -70,7 +65,7 @@ public class MavenProjectConverter implements TaskExtension { return rootProject; } - private void rebuildModuleHierarchy(Map<String, MavenProject> paths, Map<MavenProject, ProjectDefinition> defs) throws IOException { + private void rebuildModuleHierarchy(Map<String, MavenProject> paths, Map<MavenProject, ProjectDefinition> defs) { for (Map.Entry<String, MavenProject> entry : paths.entrySet()) { MavenProject pom = entry.getValue(); for (Object m : pom.getModules()) { @@ -91,27 +86,26 @@ public class MavenProjectConverter implements TaskExtension { } } - private void configureModules(List<MavenProject> poms, Map<String, MavenProject> paths, Map<MavenProject, ProjectDefinition> defs) throws IOException { + private void configureModules(List<MavenProject> poms, Map<String, MavenProject> paths, Map<MavenProject, ProjectDefinition> defs) { for (MavenProject pom : poms) { - paths.put(pom.getFile().getCanonicalPath(), pom); + paths.put(PathUtils.canonicalPath(pom.getFile()), pom); ProjectDefinition def = ProjectDefinition.create(); merge(pom, def); defs.put(pom, def); } } - private static MavenProject findMavenProject(final File modulePath, Map<String, MavenProject> paths) throws IOException { + private static MavenProject findMavenProject(final File modulePath, Map<String, MavenProject> paths) { if (modulePath.exists() && modulePath.isDirectory()) { for (Map.Entry<String, MavenProject> entry : paths.entrySet()) { String pomFileParentDir = new File(entry.getKey()).getParent(); - if (pomFileParentDir.equals(modulePath.getCanonicalPath())) { + if (pomFileParentDir.equals(PathUtils.canonicalPath(modulePath))) { return entry.getValue(); } } return null; - } else { - return paths.get(modulePath.getCanonicalPath()); } + return paths.get(PathUtils.canonicalPath(modulePath)); } @VisibleForTesting |