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 2018/01/18 09:47:49 UTC

[maven-pmd-plugin] branch master updated (b727446 -> 8968785)

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

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


    from b727446  [MPMD-128] Xref link generation regression with Maven 3
     new 3972a79  [MPMD-251] Invalid report XML is generated with includeXmlInSite=true
     new 8968785  [MPMD-251] Invalid report XML is generated with includeXmlInSite=true

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/maven/plugins/pmd/PmdReport.java    | 13 ++++++++---
 .../apache/maven/plugins/pmd/PmdReportTest.java    | 27 +++++++++++++++++++++-
 ...d-report-include-xml-in-site-plugin-config.xml} |  8 ++-----
 3 files changed, 38 insertions(+), 10 deletions(-)
 copy src/test/resources/unit/default-configuration/{default-configuration-plugin-config.xml => pmd-report-include-xml-in-site-plugin-config.xml} (87%)

-- 
To stop receiving notification emails like this one, please contact
['"commits@maven.apache.org" <co...@maven.apache.org>'].

[maven-pmd-plugin] 02/02: [MPMD-251] Invalid report XML is generated with includeXmlInSite=true

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 89687854bc1c965f26adbc78410f75e631f66088
Author: Andreas Dangel <ad...@apache.org>
AuthorDate: Thu Jan 18 10:43:40 2018 +0100

    [MPMD-251] Invalid report XML is generated with includeXmlInSite=true
    
    Use the renderer's flush method
---
 src/main/java/org/apache/maven/plugins/pmd/PmdReport.java  | 14 ++++++++++----
 .../java/org/apache/maven/plugins/pmd/PmdReportTest.java   |  2 +-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
index fe39380..2a8a897 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
@@ -233,9 +233,16 @@ public class PmdReport
         return getBundle( locale ).getString( "report.pmd.description" );
     }
 
-    public void setRulesets( String[] rules )
+    /**
+     * Configures the PMD rulesets to be used directly.
+     * Note: Usually the rulesets are configured via the property.
+     *
+     * @param rulesets the PMD rulesets to be used.
+     * @see #rulesets
+     */
+    public void setRulesets( String[] rulesets )
     {
-        rulesets = rules;
+        this.rulesets = Arrays.copyOf( rulesets, rulesets.length );
     }
 
     /**
@@ -596,7 +603,7 @@ public class PmdReport
             r.start();
             r.renderFileReport( report );
             r.end();
-            writer.flush();
+            r.flush();
 
             if ( includeXmlInSite )
             {
@@ -650,7 +657,6 @@ public class PmdReport
         {
             try
             {
-                @SuppressWarnings( "unchecked" )
                 List<String> classpath =
                     includeTests ? project.getTestClasspathElements() : project.getCompileClasspathElements();
                 getLog().debug( "Using aux classpath: " + classpath );
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
index e108f96..72afd01 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -370,7 +370,7 @@ public class PmdReportTest
         assertTrue( pmdXmlTarget.contains( "</pmd>" ) );
 
         // check that pmd.xml file has the closing element
-        String pmdXml = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.xml" ) );
+        String pmdXml = readFile( generatedXmlFile );
         assertTrue( pmdXml.contains( "</pmd>" ) );
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.

[maven-pmd-plugin] 01/02: [MPMD-251] Invalid report XML is generated with includeXmlInSite=true

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3972a7995964d31d92fc0db37b4c3aa1810a73e8
Author: Brad Flood <bf...@keyholesoftware.com>
AuthorDate: Thu Jan 18 10:25:41 2018 +0100

    [MPMD-251] Invalid report XML is generated with includeXmlInSite=true
    
    Submitted by: Brad Flood <bf...@keyholesoftware.com>
    Closes apache/maven-plugins#127
---
 .../org/apache/maven/plugins/pmd/PmdReport.java    |  1 +
 .../apache/maven/plugins/pmd/PmdReportTest.java    | 27 +++++++++-
 ...md-report-include-xml-in-site-plugin-config.xml | 62 ++++++++++++++++++++++
 3 files changed, 89 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
index e5a193d..fe39380 100644
--- a/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
+++ b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
@@ -596,6 +596,7 @@ public class PmdReport
             r.start();
             r.renderFileReport( report );
             r.end();
+            writer.flush();
 
             if ( includeXmlInSite )
             {
diff --git a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
index 9fa5891..e108f96 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
@@ -350,6 +350,31 @@ public class PmdReportTest
     }
 
     /**
+     * verify the pmd.xml file is included in the site when requested.
+     * @throws Exception
+     */
+    public void testIncludeXmlInSite()
+            throws Exception
+    {
+        File testPom = new File( getBasedir(), "src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml" );
+        PmdReport mojo = (PmdReport) lookupMojo( "pmd", testPom );
+        mojo.execute();
+
+        File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.html" );
+        assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+        // verify the pmd file is included in site
+        File generatedXmlFile = new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.xml" );
+        assertTrue( FileUtils.fileExists( generatedXmlFile.getAbsolutePath() ) );
+
+        String pmdXmlTarget = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/pmd.xml" ) );
+        assertTrue( pmdXmlTarget.contains( "</pmd>" ) );
+
+        // check that pmd.xml file has the closing element
+        String pmdXml = readFile( new File( getBasedir(), "target/test/unit/default-configuration/target/site/pmd.xml" ) );
+        assertTrue( pmdXml.contains( "</pmd>" ) );
+    }
+
+    /**
      * Read the contents of the specified file object into a string
      *
      * @param file the file to be read
@@ -374,7 +399,7 @@ public class PmdReportTest
     }
 
     /**
-     * Verify the correct working of the localtionTemp method
+     * Verify the correct working of the locationTemp method
      *
      * @throws Exception
      */
diff --git a/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml b/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml
new file mode 100644
index 0000000..dc0e98d
--- /dev/null
+++ b/src/test/resources/unit/default-configuration/pmd-report-include-xml-in-site-plugin-config.xml
@@ -0,0 +1,62 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>def.configuration</groupId>
+  <artifactId>default-configuration</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <inceptionYear>2006</inceptionYear>
+  <name>Maven PMD Plugin Default Configuration Test</name>
+  <url>http://maven.apache.org</url>
+  <build>
+    <finalName>default-configuration</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-pmd-plugin</artifactId>
+        <configuration>
+          <project implementation="org.apache.maven.plugins.pmd.stubs.DefaultConfigurationMavenProjectStub"/>
+          <outputDirectory>${basedir}/target/test/unit/default-configuration/target/site</outputDirectory>
+          <targetDirectory>${basedir}/target/test/unit/default-configuration/target</targetDirectory>
+          <format>xml</format>
+          <sourceEncoding>UTF-8</sourceEncoding>
+          <includeXmlInSite>true</includeXmlInSite>
+
+        </configuration>
+        <dependencies>
+          <dependency>
+            <groupId>pmd</groupId>
+            <artifactId>pmd</artifactId>
+            <version>3.6</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.