if (!localAnalysisScript.isPresent()) return Optional.absent();
final String sourceCodeTemplate = localAnalysisScript.get().getSourceCode();
final String serverName = enrichedSettings.settings.getServerName();
final Optional<SonarServerConfig> serverConfiguration = SonarServers.get(serverName);
final TemplateProcessor sourceCodeTemplateProcessor = TemplateProcessor.of(sourceCodeTemplate);
sourceCodeTemplateProcessor
.withProject(enrichedSettings.project)
.withModule(enrichedSettings.module);
String pathToSonarReportTemplate = localAnalysisScript.get().getPathToSonarReport();
final TemplateProcessor pathToSonarReportTemplateProcessor = TemplateProcessor.of(pathToSonarReportTemplate)
.withProject(enrichedSettings.project)
.withModule(enrichedSettings.module);
if (serverConfiguration.isPresent()) {
sourceCodeTemplateProcessor.withSonarServerConfiguration(serverConfiguration.get());
pathToSonarReportTemplateProcessor.withSonarServerConfiguration(serverConfiguration.get());
}
File workingDir = WorkingDirs.computeFrom(enrichedSettings);
sourceCodeTemplateProcessor.withWorkingDir(workingDir);
pathToSonarReportTemplateProcessor.withWorkingDir(workingDir);
final String sourceCode = sourceCodeTemplateProcessor.process();
final String pathToSonarReport = pathToSonarReportTemplateProcessor.process();
return Optional.of(new RunLocalAnalysisScriptTask(
enrichedSettings, sourceCode, pathToSonarReport, workingDir,
psiFiles));
}