ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r677383 - in /ant/core/trunk: WHATSNEW docs/manual/CoreTasks/sql.html src/main/org/apache/tools/ant/taskdefs/SQLExec.java
Date Wed, 16 Jul 2008 19:20:02 GMT
Author: mbenson
Date: Wed Jul 16 12:20:02 2008
New Revision: 677383

URL: http://svn.apache.org/viewvc?rev=677383&view=rev
Log:
<sql> "output" attribute now supports any Resource in addition to a file.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/CoreTasks/sql.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=677383&r1=677382&r2=677383&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Jul 16 12:20:02 2008
@@ -190,6 +190,8 @@
 
  * <echo> supports an "output" Resource attribute as an alternative to "file".
 
+ * <sql> "output" attribute now supports any Resource in addition to a file.
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/docs/manual/CoreTasks/sql.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/sql.html?rev=677383&r1=677382&r2=677383&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/sql.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/sql.html Wed Jul 16 12:20:02 2008
@@ -117,7 +117,10 @@
 </tr>
 <tr>
   <td width="12%" valign="top">output</td>
-  <td width="78%" valign="top">Output file for result sets (defaults to System.out)</td>
+  <td width="78%" valign="top">Output file for result sets (defaults to System.out)
+    <b>Since Ant 1.8</b> can specify any Resource that supports output (see
+    <a href="../develop.html#set-magic">note</a>).
+  </td>
   <td width="10%" valign="top">No (print to System.out by default)</td>
 </tr>
   <tr>

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=677383&r1=677382&r2=677383&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 Wed Jul 16 12:20:02
2008
@@ -25,10 +25,12 @@
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.FileProvider;
 import org.apache.tools.ant.types.resources.FileResource;
 import org.apache.tools.ant.types.resources.Union;
 
 import java.io.File;
+import java.io.OutputStream;
 import java.io.PrintStream;
 import java.io.BufferedOutputStream;
 import java.io.FileOutputStream;
@@ -153,10 +155,9 @@
     private boolean showtrailers = true;
 
     /**
-     * Results Output file.
+     * Results Output Resource.
      */
-    private File output = null;
-
+    private Resource output = null;
 
     /**
      * Action to perform if an error is found
@@ -392,6 +393,15 @@
      * @param output the output file to use for logging messages.
      */
     public void setOutput(File output) {
+        setOutput(new FileResource(getProject(), output));
+    }
+
+    /**
+     * Set the output Resource;
+     * optional, defaults to the Ant log.
+     * @param output the output Resource to store results.
+     */
+    public void setOutput(Resource output) {
         this.output = output;
     }
 
@@ -556,9 +566,17 @@
                 PrintStream out = System.out;
                 try {
                     if (output != null) {
-                        log("Opening PrintStream to output file " + output, Project.MSG_VERBOSE);
-                        out = new PrintStream(new BufferedOutputStream(
-                                new FileOutputStream(output.getAbsolutePath(), append)));
+                        log("Opening PrintStream to output Resource " + output, Project.MSG_VERBOSE);
+                        OutputStream os;
+                        if (output instanceof FileProvider) {
+                            os = new FileOutputStream(((FileProvider) output).getFile(),
append);
+                        } else {
+                            os = output.getOutputStream();
+                            if (append) {
+                                log("Ignoring append=true for non-file resource " + output,
Project.MSG_WARN);
+                            }
+                        }
+                        out = new PrintStream(new BufferedOutputStream(os));
                     }
 
                     // Process all transactions



Mime
View raw message