aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2018-11-30 15:50:31 -0600
committersonartech <sonartech@sonarsource.com>2019-01-16 09:43:06 +0100
commit6a7bae1beab100a27ff6209b7e9449715b97828d (patch)
treed252b05fc2d70ca93af50249dfbd47ecab3a77b8 /sonar-scanner-engine/src
parent389280a2c0799e9a1c29919af670fecf5f1f6933 (diff)
downloadsonarqube-6a7bae1beab100a27ff6209b7e9449715b97828d.tar.gz
sonarqube-6a7bae1beab100a27ff6209b7e9449715b97828d.zip
SONAR-11464 Add ITs
Diffstat (limited to 'sonar-scanner-engine/src')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DefaultInputModuleHierarchy.java7
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java4
3 files changed, 10 insertions, 3 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
index 2b36b3b5d28..fbbecab9fa1 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/MetadataPublisher.java
@@ -125,7 +125,7 @@ public class MetadataPublisher implements ReportPublisherStep {
while (!queue.isEmpty()) {
DefaultInputModule module = queue.removeFirst();
queue.addAll(moduleHierarchy.children(module));
- String relativePath = moduleHierarchy.relativePath(module);
+ String relativePath = moduleHierarchy.relativePathToRoot(module);
if (relativePath != null) {
builder.putModulesProjectRelativePathByKey(module.key(), relativePath);
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DefaultInputModuleHierarchy.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DefaultInputModuleHierarchy.java
index 3c9995269be..067f830edbe 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DefaultInputModuleHierarchy.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DefaultInputModuleHierarchy.java
@@ -91,4 +91,11 @@ public class DefaultInputModuleHierarchy implements InputModuleHierarchy {
return PathResolver.relativize(parentBaseDir, moduleBaseDir).orElse(null);
}
+
+ public String relativePathToRoot(DefaultInputModule module) {
+ Path rootBaseDir = root.getBaseDir();
+ Path moduleBaseDir = module.getBaseDir();
+
+ return PathResolver.relativize(rootBaseDir, moduleBaseDir).orElse(null);
+ }
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
index 744cabca3ed..466e016e62a 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
@@ -102,8 +102,8 @@ public class MetadataPublisherTest {
.setBaseDir(moduleBaseDir.toFile())
.setWorkDir(temp.newFolder()), TestInputFileBuilder.nextBatchId());
when(inputModuleHierarchy.children(rootModule)).thenReturn(Collections.singletonList(child));
- when(inputModuleHierarchy.relativePath(child)).thenReturn("modulePath");
- when(inputModuleHierarchy.relativePath(rootModule)).thenReturn("");
+ when(inputModuleHierarchy.relativePathToRoot(child)).thenReturn("modulePath");
+ when(inputModuleHierarchy.relativePathToRoot(rootModule)).thenReturn("");
branches = mock(BranchConfiguration.class);
scmConfiguration = mock(ScmConfiguration.class);
when(scmConfiguration.provider()).thenReturn(scmProvider);