Browse Source

- 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
master
Costin Manolache 25 years ago
parent
commit
e3dd337f59
5 changed files with 34 additions and 8 deletions
  1. +2
    -2
      build.xml
  2. +2
    -1
      src/main/org/apache/tools/ant/Main.java
  3. +1
    -1
      src/main/org/apache/tools/ant/Project.java
  4. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Ant.java
  5. +27
    -2
      src/main/org/apache/tools/ant/taskdefs/Get.java

+ 2
- 2
build.xml View File

@@ -14,7 +14,7 @@
<property name="ant.home" value="."/>
<property name="bin.dir" value="bin"/>
<property name="src.bin.dir" value="src/bin"/>
<property name="src.dir" value="src/main"/>
<property name="src.dir" value="${basedir}/src/main"/>
<property name="lib.dir" value="lib"/>
<property name="docs.dir" value="docs"/>
<property name="build.dir" value="build"/>
@@ -96,7 +96,7 @@
<!-- =================================================================== -->
<!-- Creates the distribution -->
<!-- =================================================================== -->
<target name="dist" depends="jar,javadocs">
<target name="dist" depends="main,jar,javadocs">
<mkdir dir="${ant.dist.dir}"/>
<mkdir dir="${ant.dist.dir}/bin"/>
<mkdir dir="${ant.dist.dir}/lib"/>


+ 2
- 1
src/main/org/apache/tools/ant/Main.java View File

@@ -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 {


+ 1
- 1
src/main/org/apache/tools/ant/Project.java View File

@@ -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);
}


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -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) {


+ 27
- 2
src/main/org/apache/tools/ant/taskdefs/Get.java View File

@@ -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 "<CODE>true</CODE>".
*
* @param v if "true" then be verbose
*/
public void setIgnoreErrors(String v) {
ignoreErrors = v;
}
}

Loading…
Cancel
Save