Browse Source

Fix location when error occurs in running antlib

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275004 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 22 years ago
parent
commit
94a192bb79
2 changed files with 19 additions and 30 deletions
  1. +14
    -25
      src/main/org/apache/tools/ant/taskdefs/Antlib.java
  2. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/Definer.java

+ 14
- 25
src/main/org/apache/tools/ant/taskdefs/Antlib.java View File

@@ -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;


+ 5
- 5
src/main/org/apache/tools/ant/taskdefs/Definer.java View File

@@ -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 <code>null</code>.


Loading…
Cancel
Save