[MCHANGELOG-86] Error with outputEncoding parameter set to UTF-8
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@769578 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/it/minimal-pom-output-encoding/pom.xml b/src/it/minimal-pom-output-encoding/pom.xml
new file mode 100644
index 0000000..2a48e5f
--- /dev/null
+++ b/src/it/minimal-pom-output-encoding/pom.xml
@@ -0,0 +1,65 @@
+<?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>minimal-pom-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>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changelog-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <outputEncoding>UTF-8</outputEncoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
diff --git a/src/it/minimal-pom-output-encoding/verify.bsh b/src/it/minimal-pom-output-encoding/verify.bsh
new file mode 100644
index 0000000..d02cdf5
--- /dev/null
+++ b/src/it/minimal-pom-output-encoding/verify.bsh
@@ -0,0 +1,33 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+ 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;
diff --git a/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java b/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
index 9732821..b22eea2 100644
--- a/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
+++ b/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
@@ -43,6 +43,7 @@
import org.codehaus.doxia.sink.Sink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.WriterFactory;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
@@ -53,6 +54,8 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -396,13 +399,21 @@
{
throw new MavenReportException( "Can't create " + outputXML.getAbsolutePath(), e );
}
+ catch ( UnsupportedEncodingException e )
+ {
+ throw new MavenReportException( "Can't create " + outputXML.getAbsolutePath(), e );
+ }
+ catch ( IOException e )
+ {
+ throw new MavenReportException( "Can't create " + outputXML.getAbsolutePath(), e );
+ }
}
return changelogList;
}
private void writeChangelogXml( List changelogList )
- throws FileNotFoundException
+ throws FileNotFoundException, UnsupportedEncodingException, IOException
{
StringBuffer changelogXml = new StringBuffer();
@@ -429,11 +440,16 @@
changelogXml.append( "\n</changelog>" );
outputXML.getParentFile().mkdirs();
-
- PrintWriter pw = new PrintWriter( new BufferedOutputStream( new FileOutputStream( outputXML ) ) );
- pw.write( changelogXml.toString() );
- pw.flush();
- pw.close();
+
+ //PrintWriter pw = new PrintWriter( new BufferedOutputStream( new FileOutputStream( outputXML ) ) );
+ //pw.write( changelogXml.toString() );
+ //pw.flush();
+ //pw.close();
+ // MCHANGELOG-86
+ Writer writer = WriterFactory.newWriter( new BufferedOutputStream( new FileOutputStream( outputXML ) ), outputEncoding );
+ writer.write( changelogXml.toString() );
+ writer.flush();
+ writer.close();
}
/**