@@ -49,6 +49,7 @@ import org.apache.tools.ant.util.CollectionUtils; | |||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
import org.apache.tools.ant.util.JavaEnvUtils; | import org.apache.tools.ant.util.JavaEnvUtils; | ||||
import org.apache.tools.ant.util.LoaderUtils; | import org.apache.tools.ant.util.LoaderUtils; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
import org.apache.tools.ant.util.VectorSet; | import org.apache.tools.ant.util.VectorSet; | ||||
import org.apache.tools.zip.ZipLong; | import org.apache.tools.zip.ZipLong; | ||||
@@ -401,6 +402,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||||
protected void log(final String message, final int priority) { | protected void log(final String message, final int priority) { | ||||
if (project != null) { | if (project != null) { | ||||
project.log(message, priority); | project.log(message, priority); | ||||
} else if (priority < Project.MSG_INFO) { | |||||
System.err.println(message); | |||||
} | } | ||||
} | } | ||||
@@ -1020,7 +1023,6 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||||
final String msg = "CLASSPATH element " + file | final String msg = "CLASSPATH element " + file | ||||
+ " is not a JAR."; | + " is not a JAR."; | ||||
log(msg, Project.MSG_WARN); | log(msg, Project.MSG_WARN); | ||||
System.err.println(msg); | |||||
return null; | return null; | ||||
} | } | ||||
jarFile = new JarFile(file); | jarFile = new JarFile(file); | ||||
@@ -1043,8 +1045,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||||
} catch (final Exception e) { | } catch (final Exception e) { | ||||
final String msg = "Unable to obtain resource from " + file + ": "; | final String msg = "Unable to obtain resource from " + file + ": "; | ||||
log(msg + e, Project.MSG_WARN); | log(msg + e, Project.MSG_WARN); | ||||
System.err.println(msg); | |||||
e.printStackTrace(); | |||||
log(StringUtils.getStackTrace(e), Project.MSG_WARN); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
@@ -27,6 +27,7 @@ import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
/** | /** | ||||
* EXPERIMENTAL | * EXPERIMENTAL | ||||
@@ -238,7 +239,7 @@ public class Classloader extends Task { | |||||
// TODO add exceptions | // TODO add exceptions | ||||
} catch (Exception ex) { | } catch (Exception ex) { | ||||
ex.printStackTrace(); | |||||
log(StringUtils.getStackTrace(ex), Project.MSG_ERR); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -40,6 +40,7 @@ import org.apache.tools.ant.types.PropertySet; | |||||
import org.apache.tools.ant.types.RedirectorElement; | import org.apache.tools.ant.types.RedirectorElement; | ||||
import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
import org.apache.tools.ant.util.KeepAliveInputStream; | import org.apache.tools.ant.util.KeepAliveInputStream; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
/** | /** | ||||
* Launcher for Java applications. Allows use of | * Launcher for Java applications. Allows use of | ||||
@@ -997,11 +998,7 @@ public class Java extends Task { | |||||
* @since 1.6.2 | * @since 1.6.2 | ||||
*/ | */ | ||||
private void log(Throwable t) { | private void log(Throwable t) { | ||||
StringWriter sw = new StringWriter(); | |||||
PrintWriter w = new PrintWriter(sw); | |||||
t.printStackTrace(w); | |||||
w.close(); | |||||
log(sw.toString(), Project.MSG_ERR); | |||||
log(StringUtils.getStackTrace(t), Project.MSG_ERR); | |||||
} | } | ||||
/** | /** | ||||
@@ -28,8 +28,10 @@ import java.util.Hashtable; | |||||
import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.Task; | import org.apache.tools.ant.Task; | ||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
/** | /** | ||||
* Keyword substitution. Input file is written to output file. | * Keyword substitution. Input file is written to output file. | ||||
@@ -80,7 +82,7 @@ public class KeySubst extends Task { | |||||
} | } | ||||
bw.flush(); | bw.flush(); | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
ioe.printStackTrace(); | |||||
log(StringUtils.getStackTrace(ioe), Project.MSG_ERR); | |||||
} finally { | } finally { | ||||
FileUtils.close(bw); | FileUtils.close(bw); | ||||
FileUtils.close(br); | FileUtils.close(br); | ||||
@@ -34,7 +34,7 @@ import org.apache.tools.ant.types.Path; | |||||
import org.apache.tools.ant.types.PropertySet; | import org.apache.tools.ant.types.PropertySet; | ||||
import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
import org.apache.tools.ant.types.ResourceCollection; | import org.apache.tools.ant.types.ResourceCollection; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
/** | /** | ||||
* Calls a given target for all defined sub-builds. This is an extension | * Calls a given target for all defined sub-builds. This is an extension | ||||
@@ -255,7 +255,7 @@ public class SubAnt extends Task { | |||||
log("Target '" + file | log("Target '" + file | ||||
+ "' failed with message '" | + "' failed with message '" | ||||
+ thrownException.getMessage() + "'.", Project.MSG_ERR); | + thrownException.getMessage() + "'.", Project.MSG_ERR); | ||||
thrownException.printStackTrace(System.err); | |||||
log(StringUtils.getStackTrace(thrownException), Project.MSG_ERR); | |||||
if (buildException == null) { | if (buildException == null) { | ||||
buildException = | buildException = | ||||
new BuildException(thrownException); | new BuildException(thrownException); | ||||
@@ -58,6 +58,7 @@ import org.apache.tools.ant.util.ClasspathUtils; | |||||
import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
import org.apache.tools.ant.util.ResourceUtils; | import org.apache.tools.ant.util.ResourceUtils; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
/** | /** | ||||
* Processes a set of XML documents via XSLT. This is | * Processes a set of XML documents via XSLT. This is | ||||
@@ -952,7 +953,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { | |||||
try { | try { | ||||
resolveProcessor(PROCESSOR_TRAX); | resolveProcessor(PROCESSOR_TRAX); | ||||
} catch (final Throwable e1) { | } catch (final Throwable e1) { | ||||
e1.printStackTrace(); | |||||
log(StringUtils.getStackTrace(e1), Project.MSG_ERR); | |||||
handleError(e1); | handleError(e1); | ||||
} | } | ||||
} | } | ||||
@@ -30,7 +30,7 @@ import org.apache.tools.ant.Project; | |||||
import org.apache.tools.ant.taskdefs.Execute; | import org.apache.tools.ant.taskdefs.Execute; | ||||
import org.apache.tools.ant.taskdefs.ExecuteStreamHandler; | import org.apache.tools.ant.taskdefs.ExecuteStreamHandler; | ||||
import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
/** | /** | ||||
* Creates new Continuus ccm task and sets it as the default. | * Creates new Continuus ccm task and sets it as the default. | ||||
@@ -322,7 +322,7 @@ public class CCMCreateTask extends Continuus implements ExecuteStreamHandler { | |||||
} // end of if () | } // end of if () | ||||
} catch (NullPointerException npe) { | } catch (NullPointerException npe) { | ||||
log("error procession stream , null pointer exception", Project.MSG_ERR); | log("error procession stream , null pointer exception", Project.MSG_ERR); | ||||
npe.printStackTrace(); | |||||
log(StringUtils.getStackTrace(npe), Project.MSG_ERR); | |||||
throw new BuildException(npe.getClass().getName()); | throw new BuildException(npe.getClass().getName()); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
log("error procession stream " + e.getMessage(), Project.MSG_ERR); | log("error procession stream " + e.getMessage(), Project.MSG_ERR); | ||||
@@ -43,6 +43,7 @@ import org.xml.sax.InputSource; | |||||
import org.xml.sax.SAXException; | import org.xml.sax.SAXException; | ||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
/** | /** | ||||
* Compiles EJB stubs and skeletons for the iPlanet Application | * Compiles EJB stubs and skeletons for the iPlanet Application | ||||
@@ -443,7 +444,7 @@ public class IPlanetEjbc { | |||||
p.destroy(); | p.destroy(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
log("An IOException has occurred while trying to execute ejbc."); | log("An IOException has occurred while trying to execute ejbc."); | ||||
e.printStackTrace(); | |||||
log(StringUtils.getStackTrace(e)); | |||||
} catch (InterruptedException e) { | } catch (InterruptedException e) { | ||||
// Do nothing | // Do nothing | ||||
} | } | ||||
@@ -40,6 +40,7 @@ import org.apache.tools.ant.types.optional.image.TransformOperation; | |||||
import org.apache.tools.ant.util.FileNameMapper; | import org.apache.tools.ant.util.FileNameMapper; | ||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
import org.apache.tools.ant.util.IdentityMapper; | import org.apache.tools.ant.util.IdentityMapper; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
import com.sun.media.jai.codec.FileSeekableStream; | import com.sun.media.jai.codec.FileSeekableStream; | ||||
@@ -392,7 +393,7 @@ public class Image extends MatchingTask { | |||||
} | } | ||||
} catch (Exception err) { | } catch (Exception err) { | ||||
err.printStackTrace(); | |||||
log(StringUtils.getStackTrace(err), Project.MSG_ERR); | |||||
throw new BuildException(err.getMessage()); | throw new BuildException(err.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -38,6 +38,7 @@ import org.apache.tools.ant.BuildListener; | |||||
import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
/** | /** | ||||
* <p>Collects all failing test <i>cases</i> and creates a new JUnit test class containing | * <p>Collects all failing test <i>cases</i> and creates a new JUnit test class containing | ||||
@@ -260,7 +261,7 @@ public class FailureRecorder extends ProjectComponent implements JUnitResultForm | |||||
createClassFooter(); | createClassFooter(); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
e.printStackTrace(); | |||||
log(StringUtils.getStackTrace(e)); | |||||
} finally { | } finally { | ||||
FileUtils.close(writer); | FileUtils.close(writer); | ||||
} | } | ||||
@@ -63,6 +63,7 @@ import org.apache.tools.ant.types.PropertySet; | |||||
import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
import org.apache.tools.ant.util.LoaderUtils; | import org.apache.tools.ant.util.LoaderUtils; | ||||
import org.apache.tools.ant.util.SplitClassLoader; | import org.apache.tools.ant.util.SplitClassLoader; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
/** | /** | ||||
* Runs JUnit tests. | * Runs JUnit tests. | ||||
@@ -1299,7 +1300,7 @@ public class JUnitTask extends Task { | |||||
+ " testcase not started or mixing ant versions?"; | + " testcase not started or mixing ant versions?"; | ||||
} | } | ||||
} catch (final Exception e) { | } catch (final Exception e) { | ||||
e.printStackTrace(); | |||||
log(StringUtils.getStackTrace(e), Project.MSG_INFO); | |||||
// ignored. | // ignored. | ||||
} finally { | } finally { | ||||
FileUtils.close(br); | FileUtils.close(br); | ||||
@@ -195,10 +195,6 @@ public class AntClassLoaderTest { | |||||
int startMessage = log.indexOf("CLASSPATH element "); | int startMessage = log.indexOf("CLASSPATH element "); | ||||
assertTrue(startMessage >= 0); | assertTrue(startMessage >= 0); | ||||
assertTrue(log.indexOf("foo.jar is not a JAR", startMessage) > 0); | assertTrue(log.indexOf("foo.jar is not a JAR", startMessage) > 0); | ||||
log = errBuffer.toString(); | |||||
startMessage = log.indexOf("CLASSPATH element "); | |||||
assertTrue(startMessage >= 0); | |||||
assertTrue(log.indexOf("foo.jar is not a JAR", startMessage) > 0); | |||||
} finally { | } finally { | ||||
System.setErr(sysErr); | System.setErr(sysErr); | ||||
} | } | ||||