aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2018-12-03 18:12:57 +0100
committersonartech <sonartech@sonarsource.com>2019-01-16 09:43:05 +0100
commit19a03e51f75d342155079b808fa879ece194a196 (patch)
tree318413f4ceab298d79cfddc5b64a16d645e9ca20 /sonar-scanner-engine
parent3a9fc2f40564404749d501d354b79a91e3df3a49 (diff)
downloadsonarqube-19a03e51f75d342155079b808fa879ece194a196.tar.gz
sonarqube-19a03e51f75d342155079b808fa879ece194a196.zip
SONAR-11465 Rework scanner logs
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java17
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultSettingsLoader.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java30
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java1
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java1
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java34
8 files changed, 44 insertions, 48 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java
index 202fbbcecfa..421dfdeb73f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java
@@ -47,8 +47,6 @@ public class GlobalAnalysisMode {
} else if (issues) {
LOG.info("Issues mode");
LOG.warn("The use of the issues mode (sonar.analysis.mode=issues) is deprecated. This mode will be dropped in the future.");
- } else {
- LOG.info("Publish mode");
}
if (mediumTestMode) {
LOG.info("Medium test mode");
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
index 2483a1dadc0..22a2905e1f0 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
@@ -127,16 +127,13 @@ public class ReportPublisher implements Startable {
}
public void execute() {
- // If this is a issues mode analysis then we should not upload reports
String taskId = null;
- if (!analysisMode.isIssues()) {
- File report = generateReportFile();
- if (properties.shouldKeepReport()) {
- LOG.info("Analysis report generated in " + reportDir);
- }
- if (!analysisMode.isMediumTest()) {
- taskId = upload(report);
- }
+ File report = generateReportFile();
+ if (properties.shouldKeepReport()) {
+ LOG.info("Analysis report generated in " + reportDir);
+ }
+ if (!analysisMode.isMediumTest()) {
+ taskId = upload(report);
}
logSuccess(taskId);
}
@@ -154,7 +151,7 @@ public class ReportPublisher implements Startable {
File reportZip = temp.newFile("scanner-report", ".zip");
ZipUtils.zipDir(reportDir.toFile(), reportZip);
stopTime = System.currentTimeMillis();
- LOG.info("Analysis reports compressed in {}ms, zip size={}", stopTime - startTime, FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(reportZip)));
+ LOG.info("Analysis report compressed in {}ms, zip size={}", stopTime - startTime, FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(reportZip)));
return reportZip;
} catch (IOException e) {
throw new IllegalStateException("Unable to prepare analysis report", e);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultSettingsLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultSettingsLoader.java
index 504c61f5c0b..47ffbe18cf1 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultSettingsLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/settings/DefaultSettingsLoader.java
@@ -57,7 +57,7 @@ public class DefaultSettingsLoader implements SettingsLoader {
Profiler profiler = Profiler.create(LOG);
if (componentKey != null) {
url += "?component=" + ScannerUtils.encodeForUrl(componentKey);
- profiler.startInfo("Load settings for component '" + componentKey + "'");
+ profiler.startInfo("Load project settings");
} else {
profiler.startInfo("Load global settings");
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java
index 3026296253b..ffe0e15f073 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java
@@ -19,19 +19,13 @@
*/
package org.sonar.scanner.scan;
-import java.nio.file.Path;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.Optional;
-import org.apache.commons.lang.StringUtils;
import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.batch.fs.internal.DefaultInputProject;
-import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.scanner.scan.filesystem.ScannerComponentIdGenerator;
@@ -72,31 +66,7 @@ public class InputModuleHierarchyProvider extends ProviderAdapter {
LOG.debug(" Base dir: {}", module.getBaseDir().toAbsolutePath().toString());
LOG.debug(" Working dir: {}", module.getWorkDir().toAbsolutePath().toString());
LOG.debug(" Module global encoding: {}, default locale: {}", module.getEncoding().displayName(), Locale.getDefault());
- logPaths(" Source paths: ", module.getBaseDir(), module.getSourceDirsOrFiles());
- logPaths(" Test paths: ", module.getBaseDir(), module.getTestDirsOrFiles());
return module;
}
- private static void logPaths(String label, Path baseDir, List<Path> paths) {
- if (!paths.isEmpty()) {
- StringBuilder sb = new StringBuilder(label);
- for (Iterator<Path> it = paths.iterator(); it.hasNext(); ) {
- Path file = it.next();
- Optional<String> relativePathToBaseDir = PathResolver.relativize(baseDir, file);
- if (!relativePathToBaseDir.isPresent()) {
- sb.append(file);
- } else if (StringUtils.isBlank(relativePathToBaseDir.get())) {
- sb.append(".");
- } else {
- sb.append(relativePathToBaseDir.get());
- }
- if (it.hasNext()) {
- sb.append(", ");
- }
- }
- LOG.info(sb.toString());
- }
- }
-
-
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java
index ea05d64e4b1..4284848a665 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java
@@ -46,6 +46,7 @@ public class InputProjectProvider extends ProviderAdapter {
// 3 Create project
project = new DefaultInputProject(projectReactor.getRoot(), scannerComponentIdGenerator.getAsInt());
+ LOG.info("Project key: {}", project.key());
LOG.info("Base dir: {}", project.getBaseDir().toAbsolutePath().toString());
LOG.info("Working dir: {}", project.getWorkDir().toAbsolutePath().toString());
LOG.debug("Project global encoding: {}, default locale: {}", project.getEncoding().displayName(), Locale.getDefault());
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java
index 50576d1d89e..3bdfdf85c01 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectBuildersExecutor.java
@@ -49,6 +49,7 @@ public class ProjectBuildersExecutor {
for (ProjectBuilder projectBuilder : projectBuilders) {
try {
+ LOG.debug("Execute project builder: {}", projectBuilder.getClass().getName());
projectBuilder.build(context);
} catch (Exception e) {
throw MessageException.of("Failed to execute project builder: " + getDescription(projectBuilder), e);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
index 578f8d120de..633efa40caa 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
@@ -329,8 +329,6 @@ public class ProjectScanContainer extends ComponentContainer {
ScanProperties properties = getComponentByType(ScanProperties.class);
properties.validate();
- LOG.info("Project key: {}", tree.root().key());
- LOG.info("Project base dir: {}", tree.root().getBaseDir());
properties.organizationKey().ifPresent(k -> LOG.info("Organization key: {}", k));
String branch = tree.root().definition().getBranch();
@@ -360,6 +358,7 @@ public class ProjectScanContainer extends ComponentContainer {
if (analysisMode.isIssues()) {
getComponentByType(IssueTransition.class).execute();
getComponentByType(JSONReport.class).execute();
+ LOG.info("ANALYSIS SUCCESSFUL");
} else {
getComponentByType(CpdExecutor.class).execute();
getComponentByType(ReportPublisher.class).execute();
@@ -367,8 +366,6 @@ public class ProjectScanContainer extends ComponentContainer {
getComponentByType(PostJobsExecutor.class).execute();
- LOG.info("ANALYSIS SUCCESSFUL");
-
if (analysisMode.isMediumTest()) {
getComponentByType(AnalysisObservers.class).notifyEndOfScanTask();
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
index bae2a44d47c..525165f18eb 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFileIndexer.java
@@ -29,15 +29,19 @@ import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Iterator;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputFile.Type;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
+import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.scanner.phases.ModuleCoverageExclusions;
import org.sonar.scanner.phases.ProjectCoverageExclusions;
import org.sonar.scanner.util.ProgressReport;
@@ -92,7 +96,10 @@ public class ProjectFileIndexer {
private void index(DefaultInputModule module, AtomicInteger excludedByPatternsCount) {
if (componentStore.allModules().size() > 1) {
- LOG.info("Indexing files from module {}", module.getName());
+ LOG.info(" Indexing files from module {}", module.getName());
+ LOG.info(" Base dir: {}", module.getBaseDir().toAbsolutePath().toString());
+ logPaths(" Source paths: ", module.getBaseDir(), module.getSourceDirsOrFiles());
+ logPaths(" Test paths: ", module.getBaseDir(), module.getTestDirsOrFiles());
}
ModuleExclusionFilters moduleExclusionFilters = new ModuleExclusionFilters(module);
ModuleCoverageExclusions moduleCoverageExclusions = new ModuleCoverageExclusions(module);
@@ -100,6 +107,31 @@ public class ProjectFileIndexer {
indexFiles(module, moduleExclusionFilters, moduleCoverageExclusions, module.getTestDirsOrFiles(), Type.TEST, excludedByPatternsCount);
}
+ private static void logPaths(String label, Path baseDir, List<Path> paths) {
+ if (!paths.isEmpty()) {
+ StringBuilder sb = new StringBuilder(label);
+ for (Iterator<Path> it = paths.iterator(); it.hasNext(); ) {
+ Path file = it.next();
+ Optional<String> relativePathToBaseDir = PathResolver.relativize(baseDir, file);
+ if (!relativePathToBaseDir.isPresent()) {
+ sb.append(file);
+ } else if (StringUtils.isBlank(relativePathToBaseDir.get())) {
+ sb.append(".");
+ } else {
+ sb.append(relativePathToBaseDir.get());
+ }
+ if (it.hasNext()) {
+ sb.append(", ");
+ }
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(sb.toString());
+ } else {
+ LOG.info(StringUtils.abbreviate(sb.toString(), 80));
+ }
+ }
+ }
+
private static String pluralizeFiles(int count) {
return count == 1 ? "file" : "files";
}