Search in sources :

Example 1 with DirectoryScanner

use of org.eclipse.jst.server.generic.internal.files.DirectoryScanner in project webtools.servertools by eclipse.

the class ServerTypeDefinitionUtil method getClasspathEntries.

public static ArrayList getClasspathEntries(String ref, ServerRuntime definition, boolean isLaunch) {
    Classpath cp = definition.getClasspath(ref);
    Iterator archives = cp.getArchive().iterator();
    ArrayList<Object> entryList = new ArrayList<Object>();
    while (archives.hasNext()) {
        ArchiveType archive = (ArchiveType) archives.next();
        String item = definition.getResolver().resolveProperties(archive.getPath());
        if (isLaunch)
            entryList.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(item)));
        else
            entryList.add(JavaCore.newLibraryEntry(new Path(item), null, null));
    }
    Iterator fileSets = cp.getFileset().iterator();
    while (fileSets.hasNext()) {
        FilesetType fileset = (FilesetType) fileSets.next();
        String dir = definition.getResolver().resolveProperties(fileset.getDir());
        Iterator includes = fileset.getInclude().iterator();
        String[] inclstr = new String[fileset.getInclude().size()];
        int i = 0;
        while (includes.hasNext()) {
            IncludeType incl = (IncludeType) includes.next();
            inclstr[i++] = definition.getResolver().resolveProperties(incl.getName());
        }
        Iterator excludes = fileset.getExclude().iterator();
        String[] exclstr = new String[fileset.getExclude().size()];
        i = 0;
        while (excludes.hasNext()) {
            ExcludeType excl = (ExcludeType) excludes.next();
            exclstr[i++] = definition.getResolver().resolveProperties(excl.getName());
        }
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir(dir);
        scanner.setIncludes(inclstr);
        scanner.setExcludes(exclstr);
        scanner.scan();
        String[] filesetFiles = scanner.getIncludedFiles();
        for (int j = 0; j < filesetFiles.length; j++) {
            String item = dir + "/" + filesetFiles[j];
            if (isLaunch)
                entryList.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(item)));
            else
                entryList.add(JavaCore.newLibraryEntry(new Path(item), null, null));
        }
    }
    return entryList;
}
Also used : Path(org.eclipse.core.runtime.Path) ArchiveType(org.eclipse.jst.server.generic.servertype.definition.ArchiveType) ArrayList(java.util.ArrayList) ExcludeType(org.eclipse.jst.server.generic.servertype.definition.ExcludeType) FilesetType(org.eclipse.jst.server.generic.servertype.definition.FilesetType) IncludeType(org.eclipse.jst.server.generic.servertype.definition.IncludeType) Classpath(org.eclipse.jst.server.generic.servertype.definition.Classpath) DirectoryScanner(org.eclipse.jst.server.generic.internal.files.DirectoryScanner) Iterator(java.util.Iterator)

Aggregations

ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Path (org.eclipse.core.runtime.Path)1 DirectoryScanner (org.eclipse.jst.server.generic.internal.files.DirectoryScanner)1 ArchiveType (org.eclipse.jst.server.generic.servertype.definition.ArchiveType)1 Classpath (org.eclipse.jst.server.generic.servertype.definition.Classpath)1 ExcludeType (org.eclipse.jst.server.generic.servertype.definition.ExcludeType)1 FilesetType (org.eclipse.jst.server.generic.servertype.definition.FilesetType)1 IncludeType (org.eclipse.jst.server.generic.servertype.definition.IncludeType)1