aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java9
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/Directory.java7
2 files changed, 11 insertions, 5 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java
index 5e1ebb651c2..c788f55ebd9 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputDir.java
@@ -21,6 +21,7 @@ package org.sonar.api.batch.fs.internal;
import java.io.File;
import java.nio.file.Path;
+import org.apache.commons.lang.StringUtils;
import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.utils.PathUtils;
@@ -67,7 +68,13 @@ public class DefaultInputDir extends DefaultInputComponent implements InputDir {
@Override
public String key() {
- return new StringBuilder().append(moduleKey).append(":").append(relativePath).toString();
+ StringBuilder sb = new StringBuilder().append(moduleKey).append(":");
+ if (StringUtils.isEmpty(relativePath)) {
+ sb.append("/");
+ } else {
+ sb.append(relativePath);
+ }
+ return sb.toString();
}
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Directory.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Directory.java
index fe72745346e..21e810aec94 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/Directory.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/Directory.java
@@ -19,14 +19,13 @@
*/
package org.sonar.api.resources;
+import javax.annotation.CheckForNull;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.WildcardPattern;
-import javax.annotation.CheckForNull;
-
/**
* @since 1.10
*/
@@ -140,8 +139,8 @@ public class Directory extends Resource {
public static Directory create(String relativePathFromBaseDir) {
Directory d = new Directory();
String normalizedPath = normalize(relativePathFromBaseDir);
- d.setKey(normalizedPath);
- d.setPath(normalizedPath);
+ d.setKey(normalizedPath == null ? SEPARATOR : normalizedPath);
+ d.setPath(normalizedPath == null ? "" : normalizedPath);
return d;
}