private Report processFilesWithPMD()

in src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java [282:310]


    private Report processFilesWithPMD(PMDConfiguration pmdConfiguration, List<File> files)
            throws MavenReportException {
        Report report = null;
        RuleSetLoader rulesetLoader =
                RuleSetLoader.fromPmdConfig(pmdConfiguration).warnDeprecated(true);
        try {
            // load the ruleset once to log out any deprecated rules as warnings
            rulesetLoader.loadFromResources(pmdConfiguration.getRuleSetPaths());
        } catch (RuleSetLoadException e1) {
            throw new MavenReportException("The ruleset could not be loaded", e1);
        }

        try (PmdAnalysis pmdAnalysis = PmdAnalysis.create(pmdConfiguration)) {
            for (File file : files) {
                pmdAnalysis.files().addFile(file.toPath());
            }
            LOG.debug("Executing PMD...");
            report = pmdAnalysis.performAnalysisAndCollectReport();
            LOG.debug(
                    "PMD finished. Found {} violations.", report.getViolations().size());
        } catch (Exception e) {
            String message = "Failure executing PMD: " + e.getLocalizedMessage();
            if (!request.isSkipPmdError()) {
                throw new MavenReportException(message, e);
            }
            LOG.warn(message, e);
        }
        return report;
    }