Search in sources :

Example 1 with Renderer

use of net.sourceforge.pmd.cpd.Renderer in project maven-plugins by apache.

the class CpdReport method writeNonHtml.

void writeNonHtml(CPD cpd) throws MavenReportException {
    Renderer r = createRenderer();
    if (r == null) {
        return;
    }
    String buffer = r.render(filterMatches(cpd.getMatches()));
    File targetFile = new File(targetDirectory, "cpd." + format);
    targetDirectory.mkdirs();
    try (Writer writer = new OutputStreamWriter(new FileOutputStream(targetFile), getOutputEncoding())) {
        writer.write(buffer);
        if (includeXmlInSite) {
            File siteDir = getReportOutputDirectory();
            siteDir.mkdirs();
            FileUtils.copyFile(targetFile, new File(siteDir, "cpd." + format));
        }
    } catch (IOException ioe) {
        throw new MavenReportException(ioe.getMessage(), ioe);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) XMLRenderer(net.sourceforge.pmd.cpd.XMLRenderer) CSVRenderer(net.sourceforge.pmd.cpd.CSVRenderer) Renderer(net.sourceforge.pmd.cpd.Renderer) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) File(java.io.File) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) MavenReportException(org.apache.maven.reporting.MavenReportException)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 CSVRenderer (net.sourceforge.pmd.cpd.CSVRenderer)1 Renderer (net.sourceforge.pmd.cpd.Renderer)1 XMLRenderer (net.sourceforge.pmd.cpd.XMLRenderer)1 MavenReportException (org.apache.maven.reporting.MavenReportException)1