You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by st...@apache.org on 2006/01/12 22:03:39 UTC
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/
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 @@
* <xslt> now accepts nested FileNameMappers e.g. <globmapper>.
Bugzilla report 37604.
-* New task loadresource that accompanies loadfile for non file resources.
+* New task <loadresource> that accompanies <loadfile> for non file resources.
* <echo> now supports an encoding when saving to a file.
* new GreedyInputHandler added.
-* add textfile attribute to the filesmatch condition.
+* add textfile attribute to the <filesmatch> condition. When true, the text
+ contents of the two files are compared, ignoring line ending differences.
-* new resourcesmatch condition.
+* new <resourcesmatch> condition.
* added the onmissingfiltersfile attribute to filterset. Bugzilla report 19845.
* added the inline handler element to the input task.
+
+* <sql> 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.<br>
See <a
href="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#setEscapeProcessing(boolean)">Statement's
- API docs</a> for details. <em>since Ant 1.6</em>.
+ API docs</a> for details. <emSsince Ant 1.6</em>.
<td width="10%" valign="top">No (default=true)</td>
</tr>
+<tr>
+ <td width="12%" valign="top">expandproperties</td>
+ <td width="78%" valign="top">Set to true to turn on property expansion in
+ nested SQL, inline in the task or nested transactions. <em>Since Ant 1.7</em>.
+ <td width="10%" valign="top">No (default=false)</td>
+</tr>
+
</table>
<h3>Parameters specified as nested elements</h3>
@@ -220,7 +227,8 @@
<p>Connects to the database given in <i>url</i> 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 </p>
+ inserting data into some_table and truncating some_other_table. Ant Properties
+ in the nested text will not be expanded.</p>
<p>Note that you may want to enclose your statements in
<code><![CDATA[</code> ... <code>]]></code> sections so you don't
@@ -238,6 +246,23 @@
]]></sql>
</pre></blockquote>
+
+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.
+
+<blockquote><pre><sql
+ driver="org.hsqldb.jdbcDriver";
+ url="jdbc:hsqldb:file:${database.dir}"
+ userid="sa"
+ password=""
+ expandProperties="true"
+ >
+ <transaction>
+ CREATE USER ${newuser} PASSWORD ${newpassword}
+ </transaction>
+</sql>
+</pre></blockquote>
+
<p>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 @@
-<html>
-<head>
-<meta http-equiv="refresh" content="1; URL=packages.html">
-<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
-<title>Apache Ant API</title>
-</head>
-<body>
-Redirecting to <a href="packages.html">Apache Ant API ...</a>
-</body>
-</html>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+<!--NewPage-->
+<HTML>
+<HEAD>
+<!-- Generated by javadoc on Mon Jan 09 14:48:52 GMT 2006-->
+<TITLE>
+Apache Ant API
+</TITLE>
+<SCRIPT type="text/javascript">
+ targetPage = "" + window.location.search;
+ if (targetPage != "" && targetPage != "undefined")
+ targetPage = targetPage.substring(1);
+ function loadFrames() {
+ if (targetPage != "" && targetPage != "undefined")
+ top.classFrame.location = top.targetPage;
+ }
+</SCRIPT>
+<NOSCRIPT>
+</NOSCRIPT>
+</HEAD>
+<FRAMESET cols="20%,80%" title="" onLoad="top.loadFrames()">
+<FRAMESET rows="30%,70%" title="" onLoad="top.loadFrames()">
+<FRAME src="overview-frame.html" name="packageListFrame" title="All Packages">
+<FRAME src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)">
+</FRAMESET>
+<FRAME src="overview-summary.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes">
+<NOFRAMES>
+<H2>
+Frame Alert</H2>
+<P>
+This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
+<BR>
+Link to<A HREF="overview-summary.html">Non-frame version.</A>
+</NOFRAMES>
+</FRAMESET>
+</HTML>
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