You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2014/01/06 18:51:50 UTC

svn commit: r1555947 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW contributors.xml manual/Tasks/sql.html src/main/org/apache/tools/ant/taskdefs/SQLExec.java

Author: bodewig
Date: Mon Jan  6 17:51:49 2014
New Revision: 1555947

URL: http://svn.apache.org/r1555947
Log:
outputencoding for sql, patch by Miroslav Zaťko.  PR 39541

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/manual/Tasks/sql.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1555947&r1=1555946&r2=1555947&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Mon Jan  6 17:51:49 2014
@@ -254,6 +254,7 @@ Michael Saunders
 Miha
 Mike Davis
 Mike Roberts
+Miroslav Zaťko
 mnowostawski
 Mounir El Hajj
 Nathan Beyer

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1555947&r1=1555946&r2=1555947&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Jan  6 17:51:49 2014
@@ -88,6 +88,9 @@ Other changes:
  * <javadoc> now has an option to fail if javadoc issues warnings.
    Bugzilla Report 55015
 
+ * <sql> has a new outputencoding attribute.
+   Bugzilla Report 39541
+
 Changes from Ant 1.9.2 TO Ant 1.9.3
 ===================================
 

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1555947&r1=1555946&r2=1555947&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Mon Jan  6 17:51:49 2014
@@ -1038,6 +1038,10 @@
     <last>Roberts</last>
   </name>
   <name>
+    <first>Miroslav</first>
+    <last>Zaťko</last>
+  </name>
+  <name>
     <last>mnowostawski</last>
   </name>
   <name>

Modified: ant/core/trunk/manual/Tasks/sql.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/sql.html?rev=1555947&r1=1555946&r2=1555947&view=diff
==============================================================================
--- ant/core/trunk/manual/Tasks/sql.html (original)
+++ ant/core/trunk/manual/Tasks/sql.html Mon Jan  6 17:51:49 2014
@@ -91,6 +91,12 @@ and <b>abort</b> execution and transacti
   <td align="center">No - defaults to default JVM encoding</td>
 </tr>
 <tr>
+  <td valign="top">outputencoding</td>
+  <td valign="top">The encoding of the files holding
+    results.  <em>since 1.9.4</em</td>
+  <td align="center">No - defaults to default JVM encoding</td>
+</tr>
+<tr>
   <td width="12%" valign="top">delimiter</td>
   <td width="78%" valign="top">String that separates SQL statements</td>
   <td width="10%" valign="top">No, default &quot;;&quot;</td>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java?rev=1555947&r1=1555946&r2=1555947&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java Mon Jan  6 17:51:49 2014
@@ -163,6 +163,11 @@ public class SQLExec extends JDBCTask {
     private Resource output = null;
 
     /**
+     * Output encoding.
+     */
+    private String outputEncoding = null;
+
+    /**
      * Action to perform if an error is found
      */
     private String onError = "abort";
@@ -429,6 +434,17 @@ public class SQLExec extends JDBCTask {
     }
 
     /**
+     * The encoding to use when writing the result to a resource.
+     * <p>Default's to the platform's default encoding</p>
+     * @param outputEncoding the name of the encoding or null for the
+     * platform's default encoding
+     * @since Ant 1.9.4
+     */
+    public void setOutputEncoding(String outputEncoding) {
+        this.outputEncoding = outputEncoding;
+    }
+
+    /**
      * whether output should be appended to or overwrite
      * an existing file.  Defaults to false.
      *
@@ -641,7 +657,12 @@ public class SQLExec extends JDBCTask {
                                 }
                             }
                         }
+                        if (outputEncoding != null) {
+                            out = new PrintStream(new BufferedOutputStream(os),
+                                                  false, outputEncoding);
+                        } else {
                         out = new PrintStream(new BufferedOutputStream(os));
+                        }
                     }
 
                     // Process all transactions