Methods Summary |
---|
public org.apache.tools.ant.types.Path | createClasspath()Adds a path to the classpath.
if (classpath == null) {
classpath = new Path(getProject());
}
return classpath.createPath();
|
public void | execute()execute it
validate();
if (classpath != null) {
getProject().log("using user supplied classpath: " + classpath,
Project.MSG_DEBUG);
classpath = classpath.concatSystemClasspath("ignore");
} else {
classpath = new Path(getProject());
classpath = classpath.concatSystemClasspath("only");
getProject().log("using system classpath: " + classpath, Project.MSG_DEBUG);
}
AntClassLoader loader;
loader = new AntClassLoader(getProject().getCoreLoader(),
getProject(),
classpath, false);
String loc = null;
if (classname != null) {
//convert a class name into a resource
resource = classname.replace('.", '/") + ".class";
}
if (resource == null) {
throw new BuildException("One of class or resource is required");
}
if (resource.startsWith("/")) {
resource = resource.substring(1);
}
log("Searching for " + resource, Project.MSG_VERBOSE);
URL url;
url = loader.getResource(resource);
if (url != null) {
//set the property
loc = url.toExternalForm();
getProject().setNewProperty(property, loc);
}
|
public void | setClass(java.lang.String classname)name the class to look for
this.classname = classname;
|
public void | setClasspath(org.apache.tools.ant.types.Path cp)Set the classpath to be used for this compilation.
if (classpath == null) {
classpath = cp;
} else {
classpath.append(cp);
}
|
public void | setProperty(java.lang.String property)the property to fill with the URL of the resource or class
this.property = property;
|
public void | setResource(java.lang.String resource)name the resource to look for
this.resource = resource;
|
private void | validate()validate
int setcount = 0;
if (classname != null) {
setcount++;
}
if (resource != null) {
setcount++;
}
if (setcount == 0) {
throw new BuildException(
"One of classname or resource must be specified");
}
if (setcount > 1) {
throw new BuildException(
"Only one of classname or resource can be specified");
}
if (property == null) {
throw new BuildException("No property defined");
}
|