aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJanos Gyerik <janos.gyerik@sonarsource.com>2017-02-23 11:49:27 +0100
committerJanos Gyerik <janos.gyerik@sonarsource.com>2017-02-23 15:15:39 +0100
commitd47bf478c722a1dd4a3c57e235a4544df3ddc7c3 (patch)
tree3d84b5b4fe8aeccda685a6d17026b385834e028b /sonar-scanner-engine
parent4abbd1f4890de33d6539bc282911c5cef83cd291 (diff)
downloadsonarqube-d47bf478c722a1dd4a3c57e235a4544df3ddc7c3.tar.gz
sonarqube-d47bf478c722a1dd4a3c57e235a4544df3ddc7c3.zip
Log as debug when sources are defined but missing in non-leaf
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java19
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java10
2 files changed, 26 insertions, 3 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
index dada0d84cf6..f642396ddea 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
@@ -333,6 +333,8 @@ public class ProjectReactorBuilder {
if (project.getSubProjects().isEmpty()) {
cleanAndCheckModuleProperties(project);
} else {
+ logMissingSourcesAndTests(project);
+
// clean modules properties as well
for (ProjectDefinition module : project.getSubProjects()) {
cleanAndCheckProjectDefinitions(module);
@@ -340,6 +342,23 @@ public class ProjectReactorBuilder {
}
}
+ private static void logMissingSourcesAndTests(ProjectDefinition project) {
+ Map<String, String> properties = project.properties();
+
+ File baseDir = project.getBaseDir();
+ logMissingPaths("source", baseDir, getListFromProperty(properties, PROPERTY_SOURCES));
+ logMissingPaths("test", baseDir, getListFromProperty(properties, PROPERTY_TESTS));
+ }
+
+ private static void logMissingPaths(String label, File baseDir, String[] paths) {
+ for (String path : paths) {
+ File file = resolvePath(baseDir, path);
+ if (!file.exists()) {
+ LOG.debug("Path '{}' does not exist, will not be used as {}", file, label);
+ }
+ }
+ }
+
@VisibleForTesting
protected static void cleanAndCheckModuleProperties(ProjectDefinition project) {
Map<String, String> properties = project.properties();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
index 26f5b87d7d9..1b63100e7d1 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
@@ -62,7 +62,7 @@ public class ProjectReactorBuilderTest {
}
@Test
- public void shouldFailIfUnexistingSourceDirectory() {
+ public void should_fail_if_sources_are_missing_in_leaf_module() {
thrown.expect(MessageException.class);
thrown.expectMessage("The folder 'unexisting-source-dir' does not exist for 'com.foo.project' (base directory = "
+ getResource(this.getClass(), "simple-project-with-unexisting-source-dir") + ")");
@@ -71,6 +71,11 @@ public class ProjectReactorBuilderTest {
}
@Test
+ public void should_not_fail_if_sources_are_missing_in_intermediate_module() {
+ loadProjectDefinition("multi-module-pom-in-root");
+ }
+
+ @Test
public void fail_if_sources_not_set() {
thrown.expect(MessageException.class);
thrown.expectMessage("You must define the following mandatory properties for 'com.foo.project': sonar.sources");
@@ -568,10 +573,9 @@ public class ProjectReactorBuilderTest {
assertThat(rootProject.getName()).isEqualTo("Foo Project");
assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT");
assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project");
- // root project must not contain some properties - even if they are defined in the root properties file
assertThat(rootProject.sources().contains("sources")).isTrue();
assertThat(rootProject.tests().contains("tests")).isTrue();
- // and module properties must have been cleaned
+ // Module properties must have been cleaned
assertThat(rootProject.properties().get("module1.sonar.projectKey")).isNull();
assertThat(rootProject.properties().get("module2.sonar.projectKey")).isNull();
// Check baseDir and workDir