ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "T Master" <tmas...@iknowledgeinc.com>
Subject loading classes in a custom task
Date Wed, 15 Aug 2001 20:46:10 GMT
Given a fileset of *.jar is passed to a custom task,  how can MyTask load
the classes it requires?   I have a classpath attribute that is a fileset.
I've passed this to my task.  As this is a collection of jar files, what now
must be done to load the class?   Code snippet appreciated.

e.g.

public class MyTask
{
    Path classpath = null;

     /**
     * Set the classpath to be used for this compilation.
     */
    public void setClasspath(Path aClasspath) {
        if (this.classpath == null) {
            this.classpath = aClasspath;
        } else {
            this.classpath.append(aClasspath);
        }
    }

    /**
     * Set the classpath to be used for this compilation.
     */
    public void addClasspath(Path aClasspath) {
        if (this.classpath == null) {
            this.classpath = aClasspath;
        } else {
            this.classpath.append(aClasspath);
        }
    }

    /**
     * Creates a nested classpath element.
     */
    public Path createClasspath() {
        if (classpath == null) {
            classpath = new Path(project);
        }
        return classpath.createPath();
    }

    /**
     * Adds a reference to a CLASSPATH defined elsewhere.
     */
    public void setClasspathRef(Reference r) {
        createClasspath().setRefid(r);
    }

     public void execute() throws BuildException() {
        .
        .
        .

        // need to load class javancss.Javancss as it is not in our system
classpath.
        javancss.Javancss ncss = new javancss.Javancss( cmdArgs,
Main.S_RCS_HEADER);
    }
}

T Master.




Mime
View raw message