@Override
public void stop() {
- if (!settings.getBoolean(KEEP_REPORT_PROP_KEY) && !settings.getBoolean(VERBOSE_KEY)) {
+ if (!shouldKeepReport()) {
deleteQuietly(reportDir);
- } else {
- LOG.info("Analysis report generated in " + reportDir);
}
}
String taskId = null;
if (!analysisMode.isIssues()) {
File report = generateReportFile();
+ if (shouldKeepReport()) {
+ LOG.info("Analysis report generated in " + reportDir);
+ }
if (!analysisMode.isMediumTest()) {
taskId = upload(report);
}
logSuccess(taskId);
}
+ private boolean shouldKeepReport() {
+ return settings.getBoolean(KEEP_REPORT_PROP_KEY) || settings.getBoolean(VERBOSE_KEY);
+ }
+
private File generateReportFile() {
try {
long startTime = System.currentTimeMillis();
private static final Logger LOG = Loggers.get(ProjectScanContainer.class);
private final AnalysisProperties props;
- private ProjectLock lock;
public ProjectScanContainer(ComponentContainer globalContainer, AnalysisProperties props) {
super(globalContainer);
@Override
protected void doBeforeStart() {
addBatchComponents();
- lock = getComponentByType(ProjectLock.class);
+ ProjectLock lock = getComponentByType(ProjectLock.class);
lock.tryLock();
getComponentByType(WorkDirectoryCleaner.class).execute();
addBatchExtensions();
}
}
- @Override
- public ComponentContainer startComponents() {
- try {
- return super.startComponents();
- } catch (Exception e) {
- // ensure that lock is released
- if (lock != null) {
- lock.stop();
- }
- throw e;
- }
- }
-
private void addBatchComponents() {
add(
props,
import org.sonar.batch.index.BatchComponentCache;
import org.sonar.batch.util.ProgressReport;
import org.sonar.scanner.protocol.output.ScannerReport;
-import org.sonar.scanner.protocol.output.ScannerReportWriter;
import org.sonar.scanner.protocol.output.ScannerReport.Changesets.Builder;
+import org.sonar.scanner.protocol.output.ScannerReportWriter;
class DefaultBlameOutput implements BlameOutput {
return NON_ASCII_CHARS.matcher(inputString).replaceAll("_");
}
- public void finish() {
+ public void finish(boolean success) {
progressReport.stop(count + "/" + total + " files analyzed");
- if (!allFilesToBlame.isEmpty()) {
+ if (success && !allFilesToBlame.isEmpty()) {
LOG.warn("Missing blame information for the following files:");
for (InputFile f : allFilesToBlame) {
LOG.warn(" * " + f.absolutePath());
DefaultBlameOutput output = new DefaultBlameOutput(publishReportJob.getWriter(), resourceCache, filesToBlame);
try {
configuration.provider().blameCommand().blame(new DefaultBlameInput(fs, filesToBlame), output);
- } finally {
- output.finish();
+ } catch (Exception e) {
+ output.finish(false);
+ throw e;
}
+ output.finish(true);
}
}