You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/03/21 17:18:41 UTC
svn commit: r639695 - in /maven/plugins/trunk/maven-ant-plugin: pom.xml
src/it/encoding-it/ src/it/encoding-it/goals.txt src/it/encoding-it/pom.xml
src/it/encoding-it/verify.bsh
src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
Author: bentmann
Date: Fri Mar 21 09:18:35 2008
New Revision: 639695
URL: http://svn.apache.org/viewvc?rev=639695&view=rev
Log:
[MANT-36] Use correct file encoding when writing build files
Added:
maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/ (with props)
maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/goals.txt (with props)
maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/pom.xml (with props)
maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/verify.bsh (with props)
Modified:
maven/plugins/trunk/maven-ant-plugin/pom.xml
maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
Modified: maven/plugins/trunk/maven-ant-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/pom.xml?rev=639695&r1=639694&r2=639695&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-ant-plugin/pom.xml Fri Mar 21 09:18:35 2008
@@ -203,14 +203,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
- <version>1.0</version>
+ <version>1.1</version>
<configuration>
<debug>true</debug>
<projectsDirectory>src/it</projectsDirectory>
<pomIncludes>
- <pomInclude>ear-it/pom.xml</pomInclude>
- <pomInclude>webapp-it/pom.xml</pomInclude>
- <pomInclude>plugin-it/pom.xml</pomInclude>
+ <pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
<postBuildHookScript>verify.bsh</postBuildHookScript>
<goals>
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Mar 21 09:18:35 2008
@@ -0,0 +1,5 @@
+target
+build.xml
+maven-build.properties
+maven-build.xml
+build.log
Added: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/goals.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/goals.txt?rev=639695&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/goals.txt (added)
+++ maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/goals.txt Fri Mar 21 09:18:35 2008
@@ -0,0 +1,2 @@
+ant:ant
+initialize
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/goals.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/goals.txt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/pom.xml?rev=639695&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/pom.xml (added)
+++ maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/pom.xml Fri Mar 21 09:18:35 2008
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.maven-ant-plugin.it</groupId>
+ <artifactId>encoding-it</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <build>
+ <!-- some non-ascii characters here -->
+ <finalName>encoding-it-äöüß</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ant-plugin</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>initialize</phase>
+ <configuration>
+ <tasks>
+ <!-- delete the properties file to prevent fallback, we want only stuff from the XML file -->
+ <delete file="${basedir}/maven-build.properties"/>
+ <ant dir="${basedir}" antfile="${basedir}/build.xml" target="package" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/verify.bsh?rev=639695&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/verify.bsh (added)
+++ maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/verify.bsh Fri Mar 21 09:18:35 2008
@@ -0,0 +1,30 @@
+import java.io.*;
+import java.util.*;
+
+try
+{
+ File targetDir = new File( basedir, "target" );
+ File[] files = targetDir.listFiles();
+ for ( int i = 0; i < files.length; i++ )
+ {
+ File file = files[i];
+ if ( file.getName().toLowerCase( Locale.ENGLISH ).endsWith( ".jar" ) )
+ {
+ if ( file.getName().indexOf( '?' ) >= 0 )
+ {
+ System.err.println( "JAR file name contains corrupted characters: " + file );
+ return false;
+ }
+ return true;
+ }
+ }
+ System.err.println( "Could not find generated JAR file" );
+ return false;
+}
+catch( Throwable t )
+{
+ t.printStackTrace();
+ return false;
+}
+
+return true;
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/verify.bsh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ant-plugin/src/it/encoding-it/verify.bsh
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java?rev=639695&r1=639694&r2=639695&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java (original)
+++ maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java Fri Mar 21 09:18:35 2008
@@ -21,8 +21,8 @@
import java.io.File;
import java.io.FileOutputStream;
-import java.io.FileWriter;
import java.io.IOException;
+import java.io.OutputStreamWriter;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -232,9 +232,13 @@
throws IOException
{
// TODO: parameter
- FileWriter w = new FileWriter( new File( project.getBasedir(), DEFAULT_MAVEN_BUILD_FILENAME ) );
+ File outputFile = new File( project.getBasedir(), DEFAULT_MAVEN_BUILD_FILENAME );
- XMLWriter writer = new PrettyPrintXMLWriter( w, StringUtils.repeat( " ", DEFAULT_INDENTATION_SIZE ), "UTF-8",
+ String encoding = "UTF-8";
+
+ OutputStreamWriter w = new OutputStreamWriter( new FileOutputStream( outputFile ), encoding );
+
+ XMLWriter writer = new PrettyPrintXMLWriter( w, StringUtils.repeat( " ", DEFAULT_INDENTATION_SIZE ), encoding,
null );
// ----------------------------------------------------------------------
@@ -322,14 +326,18 @@
private void writeBuildXml()
throws IOException
{
- if ( new File( project.getBasedir(), DEFAULT_BUILD_FILENAME ).exists() && !overwrite )
+ File outputFile = new File( project.getBasedir(), DEFAULT_BUILD_FILENAME );
+
+ if ( outputFile.exists() && !overwrite )
{
return;
}
- FileWriter w = new FileWriter( new File( project.getBasedir(), DEFAULT_BUILD_FILENAME ) );
+ String encoding = "UTF-8";
+
+ OutputStreamWriter w = new OutputStreamWriter( new FileOutputStream( outputFile ), encoding );
- XMLWriter writer = new PrettyPrintXMLWriter( w, StringUtils.repeat( " ", DEFAULT_INDENTATION_SIZE ), "UTF-8",
+ XMLWriter writer = new PrettyPrintXMLWriter( w, StringUtils.repeat( " ", DEFAULT_INDENTATION_SIZE ), encoding,
null );
// ----------------------------------------------------------------------