summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS1
-rw-r--r--WHATSNEW4
-rw-r--r--contributors.xml5
-rw-r--r--docs/manual/CoreTasks/get.html12
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/Get.java34
5 files changed, 54 insertions, 2 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 6efe8d18c..268e6dfd9 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -72,6 +72,7 @@ David Gärtner
David S. Johnson
David Kavanagh
David LeRoy
+David M. Lloyd
David Maclean
David Rees
Denis Hennessy
diff --git a/WHATSNEW b/WHATSNEW
index 438a53dee..d9f2fb3af 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -808,6 +808,10 @@ Other changes:
expression based way to determine progress based on logged messages.
Bugzilla Report 39957.
+ * the number of retries on error in <get> is now configurable. <get>
+ can be told to not download files that already exist locally.
+ Bugzilla Report 40058.
+
Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================
diff --git a/contributors.xml b/contributors.xml
index 0e31cbb4c..4b7382602 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -314,6 +314,11 @@
</name>
<name>
<first>David</first>
+ <middle>M.</middle>
+ <last>Lloyd</last>
+ </name>
+ <name>
+ <first>David</first>
<last>Maclean</last>
</name>
<name>
diff --git a/docs/manual/CoreTasks/get.html b/docs/manual/CoreTasks/get.html
index 51b239468..9f41e0a7a 100644
--- a/docs/manual/CoreTasks/get.html
+++ b/docs/manual/CoreTasks/get.html
@@ -103,6 +103,18 @@ plain text' authentication is used. This is only secure over an HTTPS link.
<td align="center" valign="top">No: default 0 which means no
maximum time</td>
</tr>
+ <tr>
+ <td valign="top">retries</td>
+ <td valign="top">the number of retries on error<br/>
+ <em>since Ant 1.8.0</em></td>
+ <td align="center" valign="top">No; default "3"</td>
+ </tr>
+ <tr>
+ <td valign="top">skipexisting</td>
+ <td valign="top">skip files that already exist on the local filesystem<br/>
+ <em>since Ant 1.8.0</em></td>
+ <td align="center" valign="top">No; default "false"</td>
+ </tr>
</table>
<h3>Examples</h3>
<pre> &lt;get src=&quot;http://ant.apache.org/&quot; dest=&quot;help/index.html&quot;/&gt;</pre>
diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java
index ba71cf3e4..f64a1272b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Get.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Get.java
@@ -65,6 +65,8 @@ public class Get extends Task {
private String uname = null;
private String pword = null;
private long maxTime = 0;
+ private int numberRetries = NUMBER_RETRIES;
+ private boolean skipExisting = false;
/**
* Does the work.
@@ -108,6 +110,12 @@ public class Get extends Task {
throws IOException {
checkAttributes();
+ if (dest.exists() && skipExisting) {
+ log("Destination already exists (skipping): "
+ + dest.getAbsolutePath(), logLevel);
+ return true;
+ }
+
//dont do any progress, unless asked
if (progress == null) {
progress = new NullProgress();
@@ -267,13 +275,35 @@ public class Get extends Task {
* The time in seconds the download is allowed to take before
* being terminated.
*
- * @since ant 1.8.0
+ * @since Ant 1.8.0
*/
public void setMaxTime(long maxTime) {
this.maxTime = maxTime;
}
/**
+ * The number of retries to attempt upon error, defaults to 3.
+ *
+ * @param r retry count
+ *
+ * @since Ant 1.8.0
+ */
+ public void setRetries(int r) {
+ this.numberRetries = r;
+ }
+
+ /**
+ * Skip files that already exist locally.
+ *
+ * @param s "true" to skip existing destination files
+ *
+ * @since Ant 1.8.0
+ */
+ public void setSkipExisting(boolean s) {
+ this.skipExisting = s;
+ }
+
+ /**
* Interface implemented for reporting
* progess of downloading.
*/
@@ -536,7 +566,7 @@ public class Get extends Task {
private boolean downloadFile()
throws FileNotFoundException, IOException {
- for (int i = 0; i < NUMBER_RETRIES; i++) {
+ for (int i = 0; i < numberRetries; i++) {
// this three attempt trick is to get round quirks in different
// Java implementations. Some of them take a few goes to bind
// property; we ignore the first couple of such failures.