Search in sources :

Example 1 with CheckstyleRssGeneratorRequest

use of org.apache.maven.plugins.checkstyle.rss.CheckstyleRssGeneratorRequest in project maven-plugins by apache.

the class AbstractCheckstyleReport method executeReport.

/** {@inheritDoc} */
public void executeReport(Locale locale) throws MavenReportException {
    checkDeprecatedParameterUsage(sourceDirectory, "sourceDirectory", "sourceDirectories");
    checkDeprecatedParameterUsage(testSourceDirectory, "testSourceDirectory", "testSourceDirectories");
    locator.addSearchPath(FileResourceLoader.ID, project.getFile().getParentFile().getAbsolutePath());
    locator.addSearchPath("url", "");
    locator.setOutputDirectory(new File(project.getBuild().getDirectory()));
    // for when we start using maven-shared-io and maven-shared-monitor...
    // locator = new Locator( new MojoLogMonitorAdaptor( getLog() ) );
    // locator = new Locator( getLog(), new File( project.getBuild().getDirectory() ) );
    ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        CheckstyleExecutorRequest request = createRequest().setLicenseArtifacts(collectArtifacts("license")).setConfigurationArtifacts(collectArtifacts("configuration")).setOmitIgnoredModules(omitIgnoredModules);
        CheckstyleResults results = checkstyleExecutor.executeCheckstyle(request);
        ResourceBundle bundle = getBundle(locale);
        generateReportStatics();
        generateMainReport(results, bundle);
        if (enableRSS) {
            CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest = new CheckstyleRssGeneratorRequest(this.project, this.getCopyright(), outputDirectory, getLog());
            checkstyleRssGenerator.generateRSS(results, checkstyleRssGeneratorRequest);
        }
    } catch (CheckstyleException e) {
        throw new MavenReportException("Failed during checkstyle configuration", e);
    } catch (CheckstyleExecutorException e) {
        throw new MavenReportException("Failed during checkstyle execution", e);
    } finally {
        //be sure to restore original context classloader
        Thread.currentThread().setContextClassLoader(currentClassLoader);
    }
}
Also used : CheckstyleResults(org.apache.maven.plugins.checkstyle.exec.CheckstyleResults) CheckstyleRssGeneratorRequest(org.apache.maven.plugins.checkstyle.rss.CheckstyleRssGeneratorRequest) CheckstyleExecutorRequest(org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorRequest) CheckstyleExecutorException(org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorException) ResourceBundle(java.util.ResourceBundle) CheckstyleException(com.puppycrawl.tools.checkstyle.api.CheckstyleException) File(java.io.File) MavenReportException(org.apache.maven.reporting.MavenReportException)

Aggregations

CheckstyleException (com.puppycrawl.tools.checkstyle.api.CheckstyleException)1 File (java.io.File)1 ResourceBundle (java.util.ResourceBundle)1 CheckstyleExecutorException (org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorException)1 CheckstyleExecutorRequest (org.apache.maven.plugins.checkstyle.exec.CheckstyleExecutorRequest)1 CheckstyleResults (org.apache.maven.plugins.checkstyle.exec.CheckstyleResults)1 CheckstyleRssGeneratorRequest (org.apache.maven.plugins.checkstyle.rss.CheckstyleRssGeneratorRequest)1 MavenReportException (org.apache.maven.reporting.MavenReportException)1