From dev-return-70691-apmail-ant-dev-archive=ant.apache.org@ant.apache.org Thu Jan 12 21:04:06 2006
Return-Path:
Delivered-To: apmail-ant-dev-archive@www.apache.org
Received: (qmail 66980 invoked from network); 12 Jan 2006 21:04:05 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199)
by minotaur.apache.org with SMTP; 12 Jan 2006 21:04:05 -0000
Received: (qmail 88264 invoked by uid 500); 12 Jan 2006 21:04:02 -0000
Delivered-To: apmail-ant-dev-archive@ant.apache.org
Received: (qmail 88230 invoked by uid 500); 12 Jan 2006 21:04:02 -0000
Mailing-List: contact dev-help@ant.apache.org; run by ezmlm
Precedence: bulk
List-Unsubscribe:
List-Help:
List-Post:
List-Id: "Ant Developers List"
Reply-To: "Ant Developers List"
Delivered-To: mailing list dev@ant.apache.org
Received: (qmail 88219 invoked by uid 500); 12 Jan 2006 21:04:02 -0000
Received: (qmail 88216 invoked by uid 99); 12 Jan 2006 21:04:02 -0000
Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49)
by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jan 2006 13:04:02 -0800
X-ASF-Spam-Status: No, hits=-9.4 required=10.0
tests=ALL_TRUSTED,NO_REAL_NAME
X-Spam-Check-By: apache.org
Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194)
by apache.org (qpsmtpd/0.29) with SMTP; Thu, 12 Jan 2006 13:04:01 -0800
Received: (qmail 66757 invoked by uid 65534); 12 Jan 2006 21:03:40 -0000
Message-ID: <20060112210340.66755.qmail@minotaur.apache.org>
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r368466 - in /ant/core/trunk: ./ docs/manual/CoreTasks/
docs/manual/api/ src/main/org/apache/tools/ant/taskdefs/
src/main/org/apache/tools/ant/types/resources/
Date: Thu, 12 Jan 2006 21:03:39 -0000
To: ant-cvs@apache.org
From: stevel@apache.org
X-Mailer: svnmailer-1.0.5
X-Virus-Checked: Checked by ClamAV on apache.org
X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N
Author: stevel
Date: Thu Jan 12 13:03:26 2006
New Revision: 368466
URL: http://svn.apache.org/viewcvs?rev=368466&view=rev
Log:
bug #38245; sql broken on Ant1.7; added expandProperties attribute to expand properties in SQL statements.
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/docs/manual/CoreTasks/sql.html
ant/core/trunk/docs/manual/api/index.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java
Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewcvs/ant/core/trunk/WHATSNEW?rev=368466&r1=368465&r2=368466&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Jan 12 13:03:26 2006
@@ -334,19 +334,24 @@
* now accepts nested FileNameMappers e.g. .
Bugzilla report 37604.
-* New task loadresource that accompanies loadfile for non file resources.
+* New task that accompanies for non file resources.
* now supports an encoding when saving to a file.
* new GreedyInputHandler added.
-* add textfile attribute to the filesmatch condition.
+* add textfile attribute to the condition. When true, the text
+ contents of the two files are compared, ignoring line ending differences.
-* new resourcesmatch condition.
+* new condition.
* added the onmissingfiltersfile attribute to filterset. Bugzilla report 19845.
* added the inline handler element to the input task.
+
+* supports property expansion if you set the expandProperties attribute. By default
+ it does not expand properties, something we dare not change for fear of breaking complex
+ SQL operations in existing files.
Changes from Ant 1.6.4 to Ant 1.6.5
===================================
Modified: ant/core/trunk/docs/manual/CoreTasks/sql.html
URL: http://svn.apache.org/viewcvs/ant/core/trunk/docs/manual/CoreTasks/sql.html?rev=368466&r1=368465&r2=368466&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/sql.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/sql.html Thu Jan 12 13:03:26 2006
@@ -146,10 +146,17 @@
object will perform escape substitution.
See Statement's
- API docs for details. since Ant 1.6.
+ API docs for details. .
No (default=true)
+
+
expandproperties
+
Set to true to turn on property expansion in
+ nested SQL, inline in the task or nested transactions. Since Ant 1.7.
+
No (default=false)
+
+
Parameters specified as nested elements
@@ -220,7 +227,8 @@
Connects to the database given in url as the sa
user using the org.database.jdbcDriver and executes the two SQL statements
- inserting data into some_table and truncating some_other_table
+ inserting data into some_table and truncating some_other_table. Ant Properties
+ in the nested text will not be expanded.
Note that you may want to enclose your statements in
<![CDATA[ ... ]]> sections so you don't
@@ -238,6 +246,23 @@
]]></sql>
+
+The following command turns property expansion in nested text on (it is off purely for backwards
+compatibility), then creates a new user in the HSQLDB database using Ant properties.
+
+
The following connects to the database given in url as the sa user using
the org.database.jdbcDriver and executes the SQL statements contained within
Modified: ant/core/trunk/docs/manual/api/index.html
URL: http://svn.apache.org/viewcvs/ant/core/trunk/docs/manual/api/index.html?rev=368466&r1=368465&r2=368466&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/api/index.html (original)
+++ ant/core/trunk/docs/manual/api/index.html Thu Jan 12 13:03:26 2006
@@ -1,12 +1,37 @@
-
-
-
-
-Apache Ant API
-
-
-Redirecting to Apache Ant API ...
-
-
-
+
+
+
+
+
+
+Apache Ant API
+
+
+
+
+
+
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java?rev=368466&r1=368465&r2=368466&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java Thu Jan 12 13:03:26 2006
@@ -300,7 +300,7 @@
*/
protected Connection getConnection() throws BuildException {
if (userId == null) {
- throw new BuildException("User Id attribute must be set!", getLocation());
+ throw new BuildException("UserId attribute must be set!", getLocation());
}
if (password == null) {
throw new BuildException("Password attribute must be set!", getLocation());
@@ -378,14 +378,17 @@
} catch (ClassNotFoundException e) {
throw new BuildException(
"Class Not Found: JDBC driver " + driver + " could not be loaded",
+ e,
getLocation());
} catch (IllegalAccessException e) {
throw new BuildException(
"Illegal Access: JDBC driver " + driver + " could not be loaded",
+ e,
getLocation());
} catch (InstantiationException e) {
throw new BuildException(
"Instantiation Exception: JDBC driver " + driver + " could not be loaded",
+ e,
getLocation());
}
return driverInstance;
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java?rev=368466&r1=368465&r2=368466&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 Thu Jan 12 13:03:26 2006
@@ -181,6 +181,14 @@
private boolean escapeProcessing = true;
/**
+ * should properties be expanded in text?
+ * false for backwards compatibility
+ *
+ * @since Ant 1.7
+ */
+ private boolean expandProperties = false;
+
+ /**
* Set the name of the SQL file to be run.
* Required unless statements are enclosed in the build file
* @param srcFile the file containing the SQL command.
@@ -190,11 +198,34 @@
}
/**
+ * Enable property expansion inside nested text
+ *
+ * @param expandProperties
+ * @since Ant 1.7
+ */
+ public void setExpandProperties(boolean expandProperties) {
+ this.expandProperties = expandProperties;
+ }
+
+ /**
+ * is property expansion inside inline text enabled?
+ *
+ * @return true if properties are to be expanded.
+ * @since Ant 1.7
+ */
+ public boolean getExpandProperties() {
+ return expandProperties;
+ }
+
+ /**
* Set an inline SQL command to execute.
- * NB: Properties are not expanded in this text.
- * @param sql a inline string containing the SQL command.
+ * NB: Properties are not expanded in this text unless {@link #expandProperties}
+ * is set.
+ * @param sql an inline string containing the SQL command.
*/
public void addText(String sql) {
+ //there is no need to expand properties here as that happens when Transaction.addText is
+ //called; to do so here would be an error.
this.sqlCommand += sql;
}
@@ -209,7 +240,7 @@
/**
* Adds a collection of resources (nested element).
- * @param set a collection of resources containing SQL commands,
+ * @param rc a collection of resources containing SQL commands,
* each resource is run in a separate transaction.
* @since Ant 1.7
*/
@@ -664,11 +695,15 @@
* @param src the source file
*/
public void setSrc(File src) {
- setSrcResource(new FileResource(src));
+ //there are places (in this file, and perhaps elsewhere, where it is assumed
+ //that null is an acceptable parameter.
+ if(src!=null) {
+ setSrcResource(new FileResource(src));
+ }
}
/**
- * Set the source file attribute.
+ * Set the source resource attribute.
* @param src the source file
* @since Ant 1.7
*/
@@ -684,7 +719,12 @@
* @param sql the inline text
*/
public void addText(String sql) {
- this.tSqlCommand += sql;
+ if (sql != null) {
+ if (getExpandProperties()) {
+ sql = getProject().replaceProperties(sql);
+ }
+ this.tSqlCommand += sql;
+ }
}
/**
Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java?rev=368466&r1=368465&r2=368466&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/FileResource.java Thu Jan 12 13:03:26 2006
@@ -277,8 +277,14 @@
* @return this FileResource formatted as a String.
*/
public String toString() {
- return isReference() ? getCheckedRef().toString()
- : FILE_UTILS.normalize(file.getAbsolutePath()).getAbsolutePath();
+ if(isReference()) {
+ return getCheckedRef().toString();
+ }
+ if(file==null) {
+ return "(unbound file resource)";
+ }
+ String absolutePath = file.getAbsolutePath();
+ return FILE_UTILS.normalize(absolutePath).getAbsolutePath();
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org