maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From micha...@apache.org
Subject svn commit: r1643612 - in /maven/plugins/trunk/maven-pmd-plugin/src: main/java/org/apache/maven/plugin/pmd/ test/java/org/apache/maven/plugin/pmd/ test/resources/unit/default-configuration/
Date Sat, 06 Dec 2014 20:50:09 GMT
Author: michaelo
Date: Sat Dec  6 20:50:09 2014
New Revision: 1643612

URL: http://svn.apache.org/r1643612
Log:
[MPMD-193] CPD's sourceEncoding not set since PMD 5.1.1 is used

Contributed-by: Tweea Tang, Andreas Dangel

Added:
    maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/cpd-encoding-configuration-plugin-config.xml
Modified:
    maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java
    maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java

Modified: maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java?rev=1643612&r1=1643611&r2=1643612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java
(original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/main/java/org/apache/maven/plugin/pmd/CpdReport.java
Sat Dec  6 20:50:09 2014
@@ -234,6 +234,7 @@ public class CpdReport
             cpdConfiguration.setMinimumTileSize( minimumTokens );
             cpdConfiguration.setLanguage( new JavaLanguage( p ) );
             cpdConfiguration.setEncoding( encoding );
+            cpdConfiguration.setSourceEncoding( encoding );
 
             cpd = new CPD( cpdConfiguration );
 

Modified: maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java?rev=1643612&r1=1643611&r2=1643612&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java
(original)
+++ maven/plugins/trunk/maven-pmd-plugin/src/test/java/org/apache/maven/plugin/pmd/CpdReportTest.java
Sat Dec  6 20:50:09 2014
@@ -239,6 +239,30 @@ public class CpdReportTest
         assertTrue(!str.toLowerCase().contains("Hello.java".toLowerCase()));
     }
 
+    public void testCpdEncodingConfiguration()
+            throws Exception
+    {
+        String originalEncoding = System.getProperty( "file.encoding" );
+        try
+        {
+            System.setProperty( "file.encoding", "UTF-16" );
+
+            File testPom = new File( getBasedir(),
+                    "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml"
);
+            CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
+            mojo.execute();
+
+            // check if the CPD files were generated
+            File generatedFile = new File( getBasedir(), "target/test/unit/default-configuration/target/cpd.xml"
);
+            assertTrue( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );
+            String str = readFile( generatedFile );
+            assertTrue(str.toLowerCase().contains("AppSample.java".toLowerCase()));
+        }
+        finally
+        {
+            System.setProperty( "file.encoding", originalEncoding );
+        }
+    }
 
     public static class MockCpd
         extends CPD

Added: maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/cpd-encoding-configuration-plugin-config.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/cpd-encoding-configuration-plugin-config.xml?rev=1643612&view=auto
==============================================================================
--- maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/cpd-encoding-configuration-plugin-config.xml
(added)
+++ maven/plugins/trunk/maven-pmd-plugin/src/test/resources/unit/default-configuration/cpd-encoding-configuration-plugin-config.xml
Sat Dec  6 20:50:09 2014
@@ -0,0 +1,61 @@
+<!--
+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>cpd-encoding-configuration</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <inceptionYear>2006</inceptionYear>
+  <name>Maven CPD Plugin Encoding 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.plugin.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>
+          <linkXRef>false</linkXRef>
+          <xrefLocation>${basedir}/target/test/unit/default-configuration/target/site/xref</xrefLocation>
+          <minimumTokens>100</minimumTokens>
+
+          <compileSourceRoots>
+            <compileSourceRoot>${basedir}/src/test/resources/unit/default-configuration/</compileSourceRoot>
+          </compileSourceRoots>
+
+          <sourceEncoding>UTF-8</sourceEncoding>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>



Mime
View raw message