Methods Summary |
---|
public void | addTask(org.apache.tools.ant.Task nestedTask)add a task to the list of tasks
tasks.add(nestedTask);
|
public static org.apache.tools.ant.taskdefs.Antlib | createAntlib(org.apache.tools.ant.Project project, java.net.URL antlibUrl, java.lang.String uri)Static method to read an ant lib definition from
a url.
// Check if we can contact the URL
try {
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.setTaskName("antlib");
antlib.init();
ue.configure(antlib);
return antlib;
} finally {
helper.exitAntLib();
}
|
public void | execute()Execute the nested tasks, setting the classloader for
any tasks that derive from Definer.
for (Iterator i = tasks.iterator(); i.hasNext();) {
UnknownElement ue = (UnknownElement) i.next();
setLocation(ue.getLocation());
ue.maybeConfigure();
Object configuredObject = ue.getRealThing();
if (configuredObject == null) {
continue;
}
if (!(configuredObject instanceof AntlibDefinition)) {
throw new BuildException(
"Invalid task in antlib " + ue.getTag()
+ " " + configuredObject.getClass() + " does not "
+ "extend org.apache.tools.ant.taskdefs.AntlibDefinition");
}
AntlibDefinition def = (AntlibDefinition) configuredObject;
def.setURI(uri);
def.setAntlibClassLoader(getClassLoader());
def.init();
def.execute();
}
|
private java.lang.ClassLoader | getClassLoader()
if (classLoader == null) {
classLoader = Antlib.class.getClassLoader();
}
return classLoader;
|
protected void | setClassLoader(java.lang.ClassLoader classLoader)Set the class loader for this antlib.
This class loader is used for any tasks that
derive from Definer.
this.classLoader = classLoader;
|
protected void | setURI(java.lang.String uri)Set the URI for this antlib.
this.uri = uri;
|