From e3dd337f59b2ee14ac818fdb89e2229e1b3922f5 Mon Sep 17 00:00:00 2001 From: Costin Manolache Date: Thu, 24 Feb 2000 00:57:43 +0000 Subject: [PATCH] - Get will try 3 times and has an option to ignore the errors - build.xml - small changes to allow build from a different directory ( usefull for nightly, which is broken ) - set ant.file == the ant file that is executing ( we also set ant.home to the home of ant ) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267615 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 4 +-- src/main/org/apache/tools/ant/Main.java | 3 +- src/main/org/apache/tools/ant/Project.java | 2 +- .../org/apache/tools/ant/taskdefs/Ant.java | 4 +-- .../org/apache/tools/ant/taskdefs/Get.java | 29 +++++++++++++++++-- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/build.xml b/build.xml index dc09bcc97..14cb16038 100644 --- a/build.xml +++ b/build.xml @@ -14,7 +14,7 @@ - + @@ -96,7 +96,7 @@ - + diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java index f044aa0c0..55e39b0b3 100644 --- a/src/main/org/apache/tools/ant/Main.java +++ b/src/main/org/apache/tools/ant/Main.java @@ -215,7 +215,8 @@ public class Main { String value = (String)definedProps.get(arg); project.setUserProperty(arg, value); } - + project.setUserProperty( "ant.file" , buildFile.getAbsolutePath() ); + // first use the ProjectHelper to create the project object // from the given build file. try { diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index 5ef7a8794..0b1aa2186 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -287,7 +287,7 @@ public class Project { throw new BuildException("Ant cannot work on Java 1.0"); } - log("Detected Java Version: " + javaVersion); + log("Detected Java Version: " + javaVersion, MSG_VERBOSE); log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java index f0f40ee8c..19b7a2234 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Ant.java +++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java @@ -103,8 +103,6 @@ public class Ant extends Task { * Do the execution. */ public void execute() throws BuildException { - if( antFile==null) throw new BuildException( "ant required antFile property "); - if( dir==null) dir="."; p1.setBasedir(dir); p1.setUserProperty("basedir" , dir); @@ -118,6 +116,8 @@ public class Ant extends Task { } if (antFile == null) antFile = dir + "/build.xml"; + + p1.setUserProperty( "ant.file" , antFile ); ProjectHelper.configureProject(p1, new File(antFile)); if (target == null) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index 5a20bb2cc..43c282596 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -66,6 +66,7 @@ public class Get extends Task { private String source; // required private String dest; // required private String verbose = ""; + String ignoreErrors=null; /** * Does the work. @@ -86,7 +87,21 @@ public class Get extends Task { File destF=new File(dest); FileOutputStream fos = new FileOutputStream(destF); - InputStream is = url.openStream(); + InputStream is=null; + for( int i=0; i< 3 ; i++ ) { + try { + is = url.openStream(); + break; + } catch( IOException ex ) { + project.log( "Error opening connection " + ex ); + } + } + if( is==null ) { + project.log( "Can't get " + source + " to " + dest); + if( ignoreErrors != null ) return; + throw new BuildException( "Can't get " + source + " to " + dest); + } + byte[] buffer = new byte[100 * 1024]; int length; @@ -98,7 +113,8 @@ public class Get extends Task { fos.close(); is.close(); } catch (IOException ioe) { - ioe.printStackTrace(); + project.log("Error getting " + source + " to " + dest ); + if( ignoreErrors != null ) return; throw new BuildException(ioe.toString()); } } @@ -129,4 +145,13 @@ public class Get extends Task { public void setVerbose(String v) { verbose = v; } + + /** + * Don't stop if get fails if set to "true". + * + * @param v if "true" then be verbose + */ + public void setIgnoreErrors(String v) { + ignoreErrors = v; + } }