Search in sources :

Example 1 with ClassPath

use of scala.tools.nsc.util.ClassPath in project zeppelin by apache.

the class SparkDependencyResolver method mergeUrlsIntoClassPath.

private MergedClassPath<AbstractFile> mergeUrlsIntoClassPath(JavaPlatform platform, URL[] urls) {
    IndexedSeq<ClassPath<AbstractFile>> entries = ((MergedClassPath<AbstractFile>) platform.classPath()).entries();
    List<ClassPath<AbstractFile>> cp = new LinkedList<>();
    for (int i = 0; i < entries.size(); i++) {
        cp.add(entries.apply(i));
    }
    for (URL url : urls) {
        AbstractFile file;
        if ("file".equals(url.getProtocol())) {
            File f = new File(url.getPath());
            if (f.isDirectory()) {
                file = AbstractFile.getDirectory(scala.reflect.io.File.jfile2path(f));
            } else {
                file = AbstractFile.getFile(scala.reflect.io.File.jfile2path(f));
            }
        } else {
            file = AbstractFile.getURL(url);
        }
        ClassPath<AbstractFile> newcp = platform.classPath().context().newClassPath(file);
        // distinct
        if (cp.contains(newcp) == false) {
            cp.add(newcp);
        }
    }
    return new MergedClassPath(scala.collection.JavaConversions.asScalaBuffer(cp).toIndexedSeq(), platform.classPath().context());
}
Also used : ClassPath(scala.tools.nsc.util.ClassPath) MergedClassPath(scala.tools.nsc.util.MergedClassPath) AbstractFile(scala.reflect.io.AbstractFile) MergedClassPath(scala.tools.nsc.util.MergedClassPath) AbstractFile(scala.reflect.io.AbstractFile) File(java.io.File) LinkedList(java.util.LinkedList) URL(java.net.URL)

Aggregations

File (java.io.File)1 URL (java.net.URL)1 LinkedList (java.util.LinkedList)1 AbstractFile (scala.reflect.io.AbstractFile)1 ClassPath (scala.tools.nsc.util.ClassPath)1 MergedClassPath (scala.tools.nsc.util.MergedClassPath)1