From d741f56d0b67fa0feb5af74c8e8f5419f980f5d3 Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Wed, 6 Dec 2000 14:12:33 +0000 Subject: [PATCH] Change behaviour to log a warning rather than throwing an exception. I had to pass in the project object to get access to logging, unfortunately. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268323 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/ProjectHelper.java | 8 ++++---- src/main/org/apache/tools/ant/taskdefs/Echo.java | 2 +- src/main/org/apache/tools/ant/taskdefs/Property.java | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index 0614f93e1..13f04939e 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -563,7 +563,7 @@ public class ProjectHelper { for (int i = 0; i < attrs.getLength(); i++) { // reflect these into the target - String value=replaceProperties(attrs.getValue(i), + String value=replaceProperties(project, attrs.getValue(i), project.getProperties() ); try { ih.setAttribute(project, target, @@ -605,7 +605,7 @@ public class ProjectHelper { /** Replace ${NAME} with the property value */ - public static String replaceProperties( String value, Hashtable keys ) + public static String replaceProperties(Project project, String value, Hashtable keys ) throws BuildException { // XXX use Map instead of proj, it's too heavy @@ -635,10 +635,10 @@ public class ProjectHelper { } String n=value.substring( pos+2, endName ); if (!keys.containsKey(n)) { - throw new BuildException("Property ${" + n + "} has not been set"); + project.log("Property ${" + n + "} has not been set", Project.MSG_WARN); } - String v = (String) keys.get(n); + String v = (keys.containsKey(n)) ? (String) keys.get(n) : "${"+n+"}"; //System.out.println("N: " + n + " " + " V:" + v); sb.append( v ); diff --git a/src/main/org/apache/tools/ant/taskdefs/Echo.java b/src/main/org/apache/tools/ant/taskdefs/Echo.java index 6e47c6e3e..ac6a12d74 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Echo.java +++ b/src/main/org/apache/tools/ant/taskdefs/Echo.java @@ -123,7 +123,7 @@ public class Echo extends Task { */ public void addText(String msg) { message += - ProjectHelper.replaceProperties(msg, project.getProperties()); + ProjectHelper.replaceProperties(project, msg, project.getProperties()); } /** diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java index fd340c79e..65e2a3fd5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Property.java +++ b/src/main/org/apache/tools/ant/taskdefs/Property.java @@ -204,7 +204,7 @@ public class Property extends Task { while (e.hasMoreElements()) { String name = (String) e.nextElement(); String value = (String) props.getProperty(name); - String v = ProjectHelper.replaceProperties(value, project.getProperties()); + String v = ProjectHelper.replaceProperties(project, value, project.getProperties()); addProperty(name, value); } } @@ -261,9 +261,9 @@ public class Property extends Task { } if (!resolved) { - value = ProjectHelper.replaceProperties(value, + value = ProjectHelper.replaceProperties(project, value, project.getProperties()); - value = ProjectHelper.replaceProperties(value, props); + value = ProjectHelper.replaceProperties(project, value, props); props.put(name, value); } }