Author: dennisl
Date: Wed Feb  8 23:00:06 2012
New Revision: 1242166

URL: http://svn.apache.org/viewvc?rev=1242166&view=rev
Log:
[MCHANGELOG-110] use ${project.reporting.outputEncoding} as default value for 
"outputEncoding" parameter and default to UTF-8

Added:
    
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/
    
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/pom.xml
   (with props)
    
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/verify.bsh
   (with props)
Modified:
    
maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/pom.xml
    
maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/verify.bsh
    maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom/verify.bsh
    
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java

Modified: 
maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/pom.xml?rev=1242166&r1=1242165&r2=1242166&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/pom.xml
 (original)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/pom.xml
 Wed Feb  8 23:00:06 2012
@@ -58,7 +58,7 @@
         <artifactId>maven-changelog-plugin</artifactId>
         <version>@pom.version@</version>
         <configuration>
-          <outputEncoding>UTF-8</outputEncoding>
+          <outputEncoding>ISO-8859-1</outputEncoding>
         </configuration>
       </plugin>
     </plugins>

Modified: 
maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/verify.bsh?rev=1242166&r1=1242165&r2=1242166&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/verify.bsh
 (original)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom-output-encoding/verify.bsh
 Wed Feb  8 23:00:06 2012
@@ -7,8 +7,8 @@ try
 {
     File outputXML = new File( basedir, "target/changelog.xml" );
     System.out.println( "Checking for existence of xml file: " + outputXML );
-    String content = FileUtils.fileRead( outputXML, "UTF-8" );
-    if ( content.indexOf( "encoding=\"UTF-8\"" ) < 0 )
+    String content = FileUtils.fileRead( outputXML, "ISO-8859-1" );
+    if ( content.indexOf( "encoding=\"ISO-8859-1\"" ) < 0 )
     {
         throw new IOException( "Wrong encoding attribute in content." );
     }

Modified: 
maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom/verify.bsh?rev=1242166&r1=1242165&r2=1242166&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom/verify.bsh 
(original)
+++ maven/plugins/trunk/maven-changelog-plugin/src/it/minimal-pom/verify.bsh 
Wed Feb  8 23:00:06 2012
@@ -7,8 +7,8 @@ try
 {
     File outputXML = new File( basedir, "target/changelog.xml" );
     System.out.println( "Checking for existence of xml file: " + outputXML );
-    String content = FileUtils.fileRead( outputXML, "ISO-8859-1" );
-    if ( content.indexOf( "encoding=\"ISO-8859-1\"" ) < 0 )
+    String content = FileUtils.fileRead( outputXML, "UTF-8" );
+    if ( content.indexOf( "encoding=\"UTF-8\"" ) < 0 )
     {
         throw new IOException( "Wrong encoding attribute in content." );
     }

Added: 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/pom.xml?rev=1242166&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/pom.xml
 Wed Feb  8 23:00:06 2012
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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 xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.changelog</groupId>
+  <artifactId>project-reporting-output-encoding</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <url>http://maven.apache.org/</url>
+
+  <scm>
+    
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-changelog-plugin/</connection>
+    
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-changelog-plugin/</developerConnection>
+    
<url>http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/</url>
+  </scm>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    
<project.reporting.outputEncoding>ISO-8859-1</project.reporting.outputEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-site-plugin</artifactId>
+        <version>@sitePluginVersion@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+  <reporting>
+    <excludeDefaults>true</excludeDefaults>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-changelog-plugin</artifactId>
+        <version>@pom.version@</version>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>

Propchange: 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author Id

Added: 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/verify.bsh?rev=1242166&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/verify.bsh
 (added)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/verify.bsh
 Wed Feb  8 23:00:06 2012
@@ -0,0 +1,42 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+import org.codehaus.plexus.util.FileUtils;
+
+try
+{
+    File outputXML = new File( basedir, "target/changelog.xml" );
+    System.out.println( "Checking for existence of xml file: " + outputXML );
+    String content = FileUtils.fileRead( outputXML, "ISO-8859-1" );
+    if ( content.indexOf( "encoding=\"ISO-8859-1\"" ) < 0 )
+    {
+        throw new IOException( "Wrong encoding attribute in content." );
+    }
+
+    File siteDir = new File( basedir, "target/site" );
+    System.out.println( "Checking for existence of site directory: " + siteDir 
);
+    if ( !siteDir.isDirectory() )
+    {
+        System.out.println( "FAILED" );
+        return false;
+    }
+
+    String[] reports = { "changelog", "dev-activity", "file-activity" };
+    for ( String report : reports )
+    {
+        File reportFile = new File( siteDir, report + ".html" );
+        System.out.println( "Checking for existence of report: " + reportFile 
);
+        if ( !reportFile.isFile() )
+        {
+            System.out.println( "FAILED" );
+            return false;
+        }
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Propchange: 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-changelog-plugin/src/it/project-reporting-output-encoding/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author Id

Modified: 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java?rev=1242166&r1=1242165&r2=1242166&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
 (original)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
 Wed Feb  8 23:00:06 2012
@@ -188,10 +188,9 @@ public class ChangeLogReport
     private String commentFormat;
 
     /**
-     * Output encoding for the xml document
+     * The file encoding when writing non-HTML reports.
      *
-     * @parameter expression="${changelog.outputEncoding}" 
default-value="ISO-8859-1"
-     * @required
+     * @parameter expression="${changelog.outputEncoding}" 
default-value="${project.reporting.outputEncoding}"
      */
     private String outputEncoding;
 
@@ -524,12 +523,12 @@ public class ChangeLogReport
             {
                 try
                 {
-                    //ReaderFactory.newReader( outputXML, outputEncoding );
+                    //ReaderFactory.newReader( outputXML, getOutputEncoding() 
);
                     //FileInputStream fIn = new FileInputStream( outputXML );
 
                     getLog().info( "Using existing changelog.xml..." );
 
-                    changelogList = ChangeLog.loadChangedSets( 
ReaderFactory.newReader( outputXML, outputEncoding ) );
+                    changelogList = ChangeLog.loadChangedSets( 
ReaderFactory.newReader( outputXML, getOutputEncoding() ) );
                 }
                 catch ( FileNotFoundException e )
                 {
@@ -580,7 +579,7 @@ public class ChangeLogReport
     {
         StringBuffer changelogXml = new StringBuffer();
 
-        changelogXml.append( "<?xml version=\"1.0\" encoding=\"" ).append( 
outputEncoding ).append( "\"?>\n" );
+        changelogXml.append( "<?xml version=\"1.0\" encoding=\"" ).append( 
getOutputEncoding() ).append( "\"?>\n" );
         changelogXml.append( "<changelog>" );
 
         for ( Iterator sets = changelogList.iterator(); sets.hasNext(); )
@@ -588,7 +587,7 @@ public class ChangeLogReport
             changelogXml.append( "\n  " );
 
             ChangeLogSet changelogSet = (ChangeLogSet) sets.next();
-            String changeset = changelogSet.toXML( outputEncoding );
+            String changeset = changelogSet.toXML( getOutputEncoding() );
 
             //remove xml header
             if ( changeset.startsWith( "<?xml" ) )
@@ -609,7 +608,7 @@ public class ChangeLogReport
         //pw.flush();
         //pw.close();
         // MCHANGELOG-86
-        Writer writer = WriterFactory.newWriter( new BufferedOutputStream( new 
FileOutputStream( outputXML ) ), outputEncoding );
+        Writer writer = WriterFactory.newWriter( new BufferedOutputStream( new 
FileOutputStream( outputXML ) ), getOutputEncoding() );
         writer.write( changelogXml.toString() );
         writer.flush();
         writer.close();
@@ -1696,6 +1695,16 @@ public class ChangeLogReport
         return outputDirectory.getAbsolutePath();
     }
 
+    /**
+     * Gets the effective reporting output files encoding.
+     *
+     * @return The effective reporting output file encoding, never 
<code>null</code>.
+     */
+    protected String getOutputEncoding()
+    {
+        return ( outputEncoding != null ) ? outputEncoding : 
ReaderFactory.UTF_8;
+    }
+
     /** {@inheritDoc} */
     protected Renderer getSiteRenderer()
     {


Reply via email to