antlibUrl.openConnection().connect();
} catch (IOException ex) {
throw new BuildException(
"Unable to find " + antlibUrl, ex);
}
ComponentHelper helper =
ComponentHelper.getComponentHelper(project);
helper.enterAntLib(uri);
try {
// Should be safe to parse
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;
} finally {
helper.exitAntLib();
}
}