diff --git a/src/main/org/apache/tools/ant/taskdefs/Antlib.java b/src/main/org/apache/tools/ant/taskdefs/Antlib.java index b32fe686f..ce845776c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Antlib.java +++ b/src/main/org/apache/tools/ant/taskdefs/Antlib.java @@ -101,33 +101,21 @@ public class Antlib extends Task implements TaskContainer { "Unable to find " + antlibUrl, ex); } // Should be safe to parse - try { - ProjectHelper2 parser = new ProjectHelper2(); - UnknownElement ue = - parser.parseUnknownElement(project, antlibUrl); - // Check name is "antlib" - if (!(ue.getTag().equals(TAG))) { - throw new BuildException( - "Unexpected tag " + ue.getTag() + " expecting " - + TAG, ue.getLocation()); - } - Antlib antlib = new Antlib(); - antlib.setProject(project); - antlib.setLocation(ue.getLocation()); - antlib.init(); - ue.configure(antlib); - return antlib; - } catch (BuildException ex) { - Location location = ex.getLocation(); - if (location == null) { - throw ex; - } + ProjectHelper2 parser = new ProjectHelper2(); + UnknownElement ue = + parser.parseUnknownElement(project, antlibUrl); + // Check name is "antlib" + if (!(ue.getTag().equals(TAG))) { throw new BuildException( - "Error in " - + System.getProperty("line.separator") - + location.toString() - + " " + ex.getMessage()); + "Unexpected tag " + ue.getTag() + " expecting " + + TAG, ue.getLocation()); } + Antlib antlib = new Antlib(); + antlib.setProject(project); + antlib.setLocation(ue.getLocation()); + antlib.init(); + ue.configure(antlib); + return antlib; } @@ -173,6 +161,7 @@ public class Antlib extends Task implements TaskContainer { for (Iterator i = tasks.iterator(); i.hasNext();) { UnknownElement ue = (UnknownElement) i.next(); ue.maybeConfigure(); + setLocation(ue.getLocation()); Task t = ue.getTask(); if (t == null) { continue; diff --git a/src/main/org/apache/tools/ant/taskdefs/Definer.java b/src/main/org/apache/tools/ant/taskdefs/Definer.java index c7ba90e3c..66bbf1e9d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Definer.java +++ b/src/main/org/apache/tools/ant/taskdefs/Definer.java @@ -408,14 +408,14 @@ public abstract class Definer extends Task { antlib.setClassLoader(classLoader); antlib.perform(); } catch (BuildException ex) { - Location location = ex.getLocation(); - if (location == null) { + Location exLocation = ex.getLocation(); + if (exLocation == null) { throw ex; } throw new BuildException( - "Error in " + "Error executing antlib" + System.getProperty("line.separator") - + getLocation().toString() + + exLocation.toString() + " " + ex.getMessage()); } } @@ -474,7 +474,7 @@ public abstract class Definer extends Task { definerSet = true; this.name = name; } - + /** * Returns the classname of the object we are defining. * May be null.