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 2008/09/16 11:01:25 UTC
svn commit: r695779 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW
contributors.xml docs/manual/CoreTasks/patch.html
src/main/org/apache/tools/ant/taskdefs/Patch.java
Author: bodewig
Date: Tue Sep 16 02:01:21 2008
New Revision: 695779
URL: http://svn.apache.org/viewvc?rev=695779&view=rev
Log:
add a fileOnError attribute to <patch>. PR 44772. Submitted by Michael Bayne.
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/WHATSNEW
ant/core/trunk/contributors.xml
ant/core/trunk/docs/manual/CoreTasks/patch.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Patch.java
Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=695779&r1=695778&r2=695779&view=diff
==============================================================================
Binary files - no diff available.
Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=695779&r1=695778&r2=695779&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Sep 16 02:01:21 2008
@@ -353,6 +353,9 @@
set.
Bugzilla Report 45711.
+ * <patch> has a new optional failOnError attribute.
+ Bugzilla Report 44772.
+
Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================
Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=695779&r1=695778&r2=695779&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Tue Sep 16 02:01:21 2008
@@ -774,6 +774,10 @@
</name>
<name>
<first>Michael</first>
+ <last>Bayne</last>
+ </name>
+ <name>
+ <first>Michael</first>
<last>Davey</last>
</name>
<name>
Modified: ant/core/trunk/docs/manual/CoreTasks/patch.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/patch.html?rev=695779&r1=695778&r2=695779&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/patch.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/patch.html Tue Sep 16 02:01:21 2008
@@ -84,6 +84,13 @@
<td valign="top">The directory in which to run the patch command.</td>
<td align="center" valign="top">No, default is the project's basedir.</td>
</tr>
+ <tr>
+ <td valign="top">failonerror</td>
+ <td valign="top">Stop the buildprocess if the command exits with a
+ return code signaling failure. Defaults to false.
+ <em>since Ant 1.8.0</em></td>
+ <td align="center" valign="top">No</td>
+ </tr>
</table>
<h3>Examples</h3>
<pre> <patch patchfile="module.1.0-1.1.patch"/></pre>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Patch.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Patch.java?rev=695779&r1=695778&r2=695779&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Patch.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Patch.java Tue Sep 16 02:01:21 2008
@@ -41,6 +41,11 @@
private Commandline cmd = new Commandline();
/**
+ * Halt on error return value from patch invocation.
+ */
+ private boolean failOnError = false;
+
+ /**
* The file to patch; optional if it can be inferred from
* the diff file
* @param file the file to patch
@@ -143,6 +148,19 @@
}
/**
+ * If <code>true</code>, stop the build process if the patch command
+ * exits with an error status.
+ * @param value <code>true</code> if it should halt, otherwise
+ * <code>false</code>. The default is <code>false</code>.
+ * @since Ant 1.8.0
+ */
+ public void setFailOnError(boolean value) {
+ failOnError = value;
+ }
+
+ private static final String PATCH = "patch";
+
+ /**
* execute patch
* @throws BuildException when it all goes a bit pear shaped
*/
@@ -152,7 +170,7 @@
getLocation());
}
Commandline toExecute = (Commandline) cmd.clone();
- toExecute.setExecutable("patch");
+ toExecute.setExecutable(PATCH);
if (originalFile != null) {
toExecute.createArgument().setFile(originalFile);
@@ -179,7 +197,16 @@
log(toExecute.describeCommand(), Project.MSG_VERBOSE);
try {
- exe.execute();
+ int returncode = exe.execute();
+ if (Execute.isFailure(returncode)) {
+ String msg = "'" + PATCH + "' failed with exit code "
+ + returncode;
+ if (failOnError) {
+ throw new BuildException(msg);
+ } else {
+ log(msg, Project.MSG_ERR);
+ }
+ }
} catch (IOException e) {
throw new BuildException(e, getLocation());
}