Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 61319 invoked from network); 11 Feb 2009 13:07:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Feb 2009 13:07:22 -0000 Received: (qmail 59073 invoked by uid 500); 11 Feb 2009 13:07:22 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 59016 invoked by uid 500); 11 Feb 2009 13:07:22 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 59007 invoked by uid 99); 11 Feb 2009 13:07:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2009 05:07:21 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2009 13:07:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BAF2723888F4; Wed, 11 Feb 2009 13:07:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r743319 - /maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java Date: Wed, 11 Feb 2009 13:07:00 -0000 To: commits@maven.apache.org From: dennisl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090211130700.BAF2723888F4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dennisl Date: Wed Feb 11 13:06:59 2009 New Revision: 743319 URL: http://svn.apache.org/viewvc?rev=743319&view=rev Log: [MWAR-183] filteringDeploymentDescriptors should honor the encoding specified in web.xml Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java?rev=743319&r1=743318&r2=743319&view=diff ============================================================================== --- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java (original) +++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java Wed Feb 11 13:06:59 2009 @@ -31,6 +31,7 @@ import org.apache.maven.shared.filtering.MavenFilteringException; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.xml.XmlStreamReader; /** * Handles the project own resources, that is: @@ -220,9 +221,8 @@ } if ( context.isFilteringDeploymentDescriptors() ) { - // TODO: web.xml encoding can be different from UTF-8 context.getMavenFileFilter().copyFile( webXml, new File( webinfDir, "web.xml" ), true, - context.getFilterWrappers(), "UTF-8" ); + context.getFilterWrappers(), getEncoding( webXml ) ); } else { @@ -238,9 +238,8 @@ // if exists we can filter it if ( defaultWebXml.exists() && context.isFilteringDeploymentDescriptors() ) { - // TODO: web.xml encoding can be different from UTF-8 context.getMavenFileFilter().copyFile( defaultWebXml, new File( webinfDir, "web.xml" ), true, - context.getFilterWrappers(), "UTF-8" ); + context.getFilterWrappers(), getEncoding( defaultWebXml ) ); context.getWebappStructure().getFullStructure().add( WEB_INF_PATH + "/web.xml" ); } } @@ -250,9 +249,9 @@ String xmlFileName = containerConfigXML.getName(); if ( context.isFilteringDeploymentDescriptors() ) { - // TODO: XML config file encoding can be different from UTF-8 context.getMavenFileFilter().copyFile( containerConfigXML, new File( metainfDir, xmlFileName ), - true, context.getFilterWrappers(), "UTF-8" ); + true, context.getFilterWrappers(), + getEncoding( containerConfigXML ) ); } else { @@ -272,6 +271,19 @@ } } + /** + * Get the encoding from an XML-file. + * + * @param webXml the XML-file + * @return The encoding of the XML-file, or UTF-8 if it's not specified in the file + * @throws IOException if an error occurred while reading the file + */ + private String getEncoding( File webXml ) + throws IOException + { + XmlStreamReader xmlReader = new XmlStreamReader( webXml ); + return xmlReader.getEncoding(); + } /** * Copies webapp webResources from the specified directory.