You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ad...@apache.org on 2021/01/08 09:02:29 UTC

[maven-pmd-plugin] 01/02: [MPMD-314] Report extension not set correctly for custom format

This is an automated email from the ASF dual-hosted git repository.

adangel pushed a commit to branch pr-41
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git

commit 5ad9c5322989411340e3533a7dde2d07b9c58c2e
Author: Hedley Proctor <he...@ICEInsureTech.com>
AuthorDate: Mon Jan 4 23:50:40 2021 +0000

    [MPMD-314] Report extension not set correctly for custom format
    
    Report file extension not set correctly when custom format (class name)
    is specified. The extension is currently set to match the format,
    as in "csv", "html". This fails when you specify the format as a fully
    qualified class name. Since the renderer interface includes a method
    defaultFileExtension(), we should use this instead to set the file
    extension.
---
 src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java b/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java
index eae9253..9fec621 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/exec/PmdExecutor.java
@@ -402,6 +402,7 @@ public class PmdExecutor extends Executor
         File targetDir = new File( request.getTargetDirectory() );
         targetDir.mkdirs();
         File targetFile = new File( targetDir, "pmd." + extension );
+        LOG.debug( "Target PMD output file: {}", targetFile  );
         try ( Writer writer = new OutputStreamWriter( new FileOutputStream( targetFile ),
                 request.getOutputEncoding() ) )
         {
@@ -429,7 +430,7 @@ public class PmdExecutor extends Executor
             throws MavenReportException
     {
         Renderer renderer = createRenderer( request.getFormat(), request.getOutputEncoding() );
-        writeReport( report, renderer, request.getFormat() );
+        writeReport( report, renderer, renderer.defaultFileExtension() );
     }
 
     /**
@@ -441,6 +442,7 @@ public class PmdExecutor extends Executor
      */
     public static Renderer createRenderer( String format, String outputEncoding ) throws MavenReportException
     {
+        LOG.debug( "Renderer requested: {}", format );
         Renderer result = null;
         if ( "xml".equals( format ) )
         {