aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-03 18:21:54 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-03 18:22:54 +0200
commit7a3e86c3f386851c3f46f141e329827eb569d718 (patch)
tree6b9b10b3b4ff87783f0cb0e0911ea0837f9a76eb /sonar-batch/src
parent3641dbcc16ad55b3b234719bb4e4cc7eae722052 (diff)
downloadsonarqube-7a3e86c3f386851c3f46f141e329827eb569d718.tar.gz
sonarqube-7a3e86c3f386851c3f46f141e329827eb569d718.zip
SONAR-5419 Improve logging of source folders
Diffstat (limited to 'sonar-batch/src')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java33
1 files changed, 24 insertions, 9 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java
index 8a3e7b6f44b..3238b870e43 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java
@@ -20,13 +20,14 @@
package org.sonar.batch.scan.filesystem;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Joiner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.BatchComponent;
+import org.sonar.api.scan.filesystem.PathResolver;
import java.io.File;
import java.nio.charset.Charset;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
@@ -45,11 +46,11 @@ public class FileSystemLogger implements BatchComponent {
@VisibleForTesting
void doLog(Logger logger) {
logDir(logger, "Base dir: ", fs.baseDir());
- logDir(logger, "Working dir: ", fs.workingDir());
- logDirs(logger, "Source dirs: ", fs.sourceDirs());
- logDirs(logger, "Test dirs: ", fs.testDirs());
- logDirs(logger, "Binary dirs: ", fs.binaryDirs());
- logEncoding(logger, fs.sourceCharset());
+ logDir(logger, "Working dir: ", fs.workDir());
+ logPaths(logger, "Source paths: ", fs.baseDir(), fs.sources());
+ logPaths(logger, "Test paths: ", fs.baseDir(), fs.tests());
+ logPaths(logger, "Binary dirs: ", fs.baseDir(), fs.binaryDirs());
+ logEncoding(logger, fs.encoding());
}
private void logEncoding(Logger logger, Charset charset) {
@@ -60,9 +61,23 @@ public class FileSystemLogger implements BatchComponent {
}
}
- private void logDirs(Logger logger, String label, List<File> dirs) {
- if (!dirs.isEmpty()) {
- logger.info(label + Joiner.on(", ").join(dirs));
+ private void logPaths(Logger logger, String label, File baseDir, List<File> paths) {
+ if (!paths.isEmpty()) {
+ PathResolver resolver = new PathResolver();
+ StringBuilder sb = new StringBuilder(label);
+ for (Iterator<File> it = paths.iterator(); it.hasNext();) {
+ File file = it.next();
+ String relativePathToBaseDir = resolver.relativePath(baseDir, file);
+ if (relativePathToBaseDir != null) {
+ sb.append(relativePathToBaseDir);
+ } else {
+ sb.append(file);
+ }
+ if (it.hasNext()) {
+ sb.append(", ");
+ }
+ }
+ logger.info(sb.toString());
}
}