You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2007/05/31 23:18:44 UTC

svn commit: r543262 - /maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java

Author: dennisl
Date: Thu May 31 14:18:43 2007
New Revision: 543262

URL: http://svn.apache.org/viewvc?view=rev&rev=543262
Log:
[MCHANGELOG-59] Apply proper formating in the report for newlines in SCM comments.

Modified:
    maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java

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?view=diff&rev=543262&r1=543261&r2=543262
==============================================================================
--- 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 Thu May 31 14:18:43 2007
@@ -45,11 +45,14 @@
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.StringReader;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -984,7 +987,44 @@
         //doRevision( entry.getFiles(), bundle, sink );
         doChangedFiles( entry.getFiles(), sink );
         sink.lineBreak();
-        sink.text( entry.getComment() );
+        StringReader sr = new StringReader( entry.getComment() );
+        BufferedReader br = new BufferedReader( sr );
+        String line;
+        try
+        {
+            line = br.readLine();
+            while ( line != null )
+            {
+                sink.text( line );
+                line = br.readLine();
+                if ( line != null )
+                {
+                    sink.lineBreak();
+                }
+            }
+        }
+        catch ( IOException e )
+        {
+            getLog().warn( "Unable to read the comment of a ChangeSet as a stream." );
+        }
+        finally
+        {
+            if ( br != null )
+            {
+                try
+                {
+                    br.close();
+                }
+                catch ( IOException e )
+                {
+                    getLog().warn( "Unable to close a reader." );
+                }
+            }
+            if ( sr != null )
+            {
+                sr.close();
+            }
+        }
         sink.tableCell_();
 
         sink.tableRow_();
@@ -1027,6 +1067,7 @@
      * generates the section of the report listing all the files revisions
      *
      * @param files list of files to generate the reports from
+     * @param sink  the report formatting tool
      */
     private void doChangedFiles( List files, Sink sink )
     {