diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index 9d6eac8f6..6a53770fe 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -360,6 +360,8 @@ public class ProjectHelper { if (target != null) { task.setOwningTarget(target); target.addTask(task); + } else { + task.execute(); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java index 2e274d0a3..ad8139ad1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Property.java +++ b/src/main/org/apache/tools/ant/taskdefs/Property.java @@ -107,7 +107,7 @@ public class Property extends Task { return resource; } - public void init() throws BuildException { + public void execute() throws BuildException { try { if ((name != null) && (value != null)) { addProperty(name, value); @@ -118,7 +118,7 @@ public class Property extends Task { if (resource != null) loadResource(resource); } catch (Exception e) { - throw new BuildException(e); + throw new BuildException(e, location); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Taskdef.java b/src/main/org/apache/tools/ant/taskdefs/Taskdef.java index 3c96eb68b..c59dae167 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Taskdef.java +++ b/src/main/org/apache/tools/ant/taskdefs/Taskdef.java @@ -65,15 +65,9 @@ public class Taskdef extends Task { private String name; private String value; - // - // REVISIT: Is this the right thing to do? - // I moved the body of execute() into init(). - // - akv - // - public void init() throws BuildException { - try { + public void execute() throws BuildException { if (name==null || value==null ) { - String msg = "name or class attributes of taskdef element " + String msg = "name or classname attributes of taskdef element " + "are undefined"; throw new BuildException(msg); } @@ -83,24 +77,14 @@ public class Taskdef extends Task { } catch (ClassNotFoundException cnfe) { String msg = "taskdef class " + value + " cannot be found"; - throw new BuildException(msg); + throw new BuildException(msg, location); } - } catch (Exception ex) { - ex.printStackTrace(); - } } public void setName( String name) { this.name = name; } - public void XsetClass(String v) { - log("The class attribute is deprecated. " + - "Please use the classname attribute.", - Project.MSG_WARN); - value = v; - } - public String getClassname() { return value; }