@Override public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) { Collection<IFile> filesToAnalyze = request.getFilesToAnalyze().stream().filter(fileValidator).collect(Collectors.toList()); try { Path jsonPath = configureCProject(request.getProject(), filesToAnalyze, jsonFactory); core.debug("Wrote build info to: " + jsonPath.toString()); request.getSonarProjectProperties().put(CFAMILY_USE_CACHE, Boolean.FALSE.toString()); request .getSonarProjectProperties() .put(BUILD_WRAPPER_OUTPUT_PROP, jsonPath.getParent().toString()); } catch (Exception e) { core.error(e.getMessage(), e); } }
private Path configureCProject( IProject project, Collection<IFile> filesToAnalyze, BuildWrapperJsonFactory jsonFactory) throws IOException { Map<String, IScannerInfo> filesInfo = new HashMap<>(); IScannerInfoProvider infoProvider = cCorePlugin.getScannerInfoProvider(project); for (IFile file : filesToAnalyze) { try { Path path = filePathResolver.getPath(file); IScannerInfo fileInfo = infoProvider.getScannerInformation(file); filesInfo.put(path.toString(), fileInfo); } catch (CoreException e) { core.error("Error building input file for SonarLint analysis: " + file.getName(), e); } } Path projectBaseDir = getProjectBaseDir(project); String json = jsonFactory.create(filesInfo, projectBaseDir.toString()); return createJsonFile(filePathResolver.getWorkDir(), json); }