Fix default encoding (UTF-8 for XML) and ensure that the encoding used is the same in the model and in the stream
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@498855 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
84cabde8de
commit
74b1736888
@ -16,14 +16,6 @@ package org.apache.maven.artifact;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.jelly.JellyContext;
|
import org.apache.commons.jelly.JellyContext;
|
||||||
import org.apache.maven.MavenException;
|
import org.apache.maven.MavenException;
|
||||||
import org.apache.maven.MavenUtils;
|
import org.apache.maven.MavenUtils;
|
||||||
@ -35,6 +27,17 @@ import org.apache.maven.project.io.stax.MavenStaxReader;
|
|||||||
import org.apache.maven.project.io.stax.MavenStaxWriter;
|
import org.apache.maven.project.io.stax.MavenStaxWriter;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewrite a full model for publishing. Inheritence and expression will have been resolved.
|
* Rewrite a full model for publishing. Inheritence and expression will have been resolved.
|
||||||
*
|
*
|
||||||
@ -47,16 +50,16 @@ public class PomRewriter
|
|||||||
throws MavenException
|
throws MavenException
|
||||||
{
|
{
|
||||||
final Model model = PomRewriter.getRewrittenModel( project.getFile(), project.getContext() );
|
final Model model = PomRewriter.getRewrittenModel( project.getFile(), project.getContext() );
|
||||||
|
if ( model.getModelEncoding() == null )
|
||||||
FileWriter w = null;
|
model.setModelEncoding( "UTF-8" );
|
||||||
|
Writer w = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final MavenStaxWriter writer = new MavenStaxWriter();
|
final MavenStaxWriter writer = new MavenStaxWriter();
|
||||||
final File f = File.createTempFile( "maven-artifact-plugin.", null );
|
final File f = File.createTempFile( "maven-artifact-plugin.", null );
|
||||||
f.deleteOnExit();
|
f.deleteOnExit();
|
||||||
w = new FileWriter( f );
|
w = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( f ), model.getModelEncoding() ) );
|
||||||
writer.write( w, model );
|
writer.write( w, model );
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
catch ( final Exception e )
|
catch ( final Exception e )
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user