From cf745efc643f19d35c8c7b0df23b26a6c8ac5bd6 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 7 Jan 2002 15:01:13 +0000 Subject: [PATCH] Improve logging when is being used as a condition. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270616 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/Available.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java index 0cd62dd47..a5c9501c9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Available.java +++ b/src/main/org/apache/tools/ant/taskdefs/Available.java @@ -84,6 +84,7 @@ public class Available extends Task implements Condition { private Path classpath; private AntClassLoader loader; private String value = "true"; + private boolean isTask = false; public void setClasspath(Path classpath) { createClasspath().append(classpath); @@ -155,6 +156,7 @@ public class Available extends Task implements Condition { throw new BuildException("property attribute is required", location); } + isTask = true; if (eval()) { String lSep = System.getProperty("line.separator"); if (null != project.getProperty(property)) { @@ -165,6 +167,7 @@ public class Available extends Task implements Condition { } this.project.setProperty(property, value); } + isTask = false; } public boolean eval() throws BuildException { @@ -183,22 +186,29 @@ public class Available extends Task implements Condition { this.loader = new AntClassLoader(project, classpath); } + String appendix = ""; + if (isTask) { + appendix = " to set property " + property; + } else { + setTaskName("available"); + } + if ((classname != null) && !checkClass(classname)) { - log("Unable to load class " + classname + " to set property " + property, Project.MSG_VERBOSE); + log("Unable to load class " + classname + appendix, Project.MSG_VERBOSE); return false; } if ((file != null) && !checkFile()) { if (type != null) { - log("Unable to find " + type + " " + file + " to set property " + property, Project.MSG_VERBOSE); + log("Unable to find " + type + " " + file + appendix, Project.MSG_VERBOSE); } else { - log("Unable to find " + file + " to set property " + property, Project.MSG_VERBOSE); + log("Unable to find " + file + appendix, Project.MSG_VERBOSE); } return false; } if ((resource != null) && !checkResource(resource)) { - log("Unable to load resource " + resource + " to set property " + property, Project.MSG_VERBOSE); + log("Unable to load resource " + resource + appendix, Project.MSG_VERBOSE); return false; } @@ -206,6 +216,10 @@ public class Available extends Task implements Condition { loader.cleanup(); } + if (!isTask) { + setTaskName(null); + } + return true; }