From beb22f14908c329930e4ea4dd8d97dca74f06d34 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 17 Jul 2002 15:40:14 +0000 Subject: [PATCH] Make build files that rely on Ant 1.5's behavior work again. These build files rely on the fact that references to top level data types get added before the data type's child elements have been added. In a case like The toString method will return "" before the fileset has been added but throw a BuildException afterwards. A logging statement in Project#addReference will call toString and thus make the build fail, while it would work in 1.5 as long as you never use the path. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273127 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/Project.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index d57286333..5cf7e0708 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -1777,7 +1777,17 @@ public class Project { log("Overriding previous definition of reference to " + name, MSG_WARN); } - log("Adding reference: " + name + " -> " + value, MSG_DEBUG); + + String valueAsString = ""; + try { + valueAsString = value.toString(); + } catch (Throwable t) { + log("Caught exception (" + t.getClass().getName() +")" + + " while expanding " + name + ": " + t.getMessage(), + MSG_WARN); + } + log("Adding reference: " + name + " -> " + valueAsString, + MSG_DEBUG); references.put(name, value); } }