git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@368466 13f79535-47bb-0310-9956-ffa450edef68master
@@ -334,20 +334,25 @@ Other changes: | |||
* <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 | |||
=================================== | |||
@@ -146,10 +146,17 @@ and <b>abort</b> execution and transaction and fail task.</p> | |||
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 @@ truncate table some_other_table; | |||
<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 | |||
@@ -239,6 +247,23 @@ update some_table set column1 = column1 + 1 where column2 < 42; | |||
]]></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 | |||
the files data1.sql, data2.sql and data3.sql and then executes the truncate | |||
@@ -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> |
@@ -300,7 +300,7 @@ public abstract class JDBCTask extends Task { | |||
*/ | |||
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 @@ public abstract class JDBCTask extends Task { | |||
} 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; | |||
@@ -180,6 +180,14 @@ public class SQLExec extends JDBCTask { | |||
*/ | |||
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 | |||
@@ -189,12 +197,35 @@ public class SQLExec extends JDBCTask { | |||
this.srcFile = srcFile; | |||
} | |||
/** | |||
* 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 @@ public class SQLExec extends JDBCTask { | |||
/** | |||
* 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 @@ public class SQLExec extends JDBCTask { | |||
* @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 @@ public class SQLExec extends JDBCTask { | |||
* @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; | |||
} | |||
} | |||
/** | |||
@@ -277,8 +277,14 @@ public class FileResource extends Resource implements Touchable { | |||
* @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(); | |||
} | |||
/** | |||