use of org.eclipse.jst.server.generic.servertype.definition.Classpath 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;
}
use of org.eclipse.jst.server.generic.servertype.definition.Classpath in project webtools.servertools by eclipse.
the class ServerRuntimeMergeUtil method containsClasspath.
private static boolean containsClasspath(List properties, String id) {
boolean found = false;
Iterator iter = properties.iterator();
while (iter.hasNext()) {
Classpath classpath = (Classpath) iter.next();
if (classpath.getId().equals(id)) {
found = true;
break;
}
}
return found;
}
use of org.eclipse.jst.server.generic.servertype.definition.Classpath in project webtools.servertools by eclipse.
the class ServerRuntimeUtils method verifyClasspath.
public static void verifyClasspath(List classpaths, String id) {
boolean found = false;
int count = 0;
Iterator iter = classpaths.iterator();
while (iter.hasNext()) {
Classpath cp = (Classpath) iter.next();
if (cp.getId().equals(id)) {
found = true;
++count;
}
}
assertTrue("Classpath not found", found);
assertEquals("More than one classpath found", 1, count);
}
use of org.eclipse.jst.server.generic.servertype.definition.Classpath in project webtools.servertools by eclipse.
the class ServerTypeDefinitionModelTest method testClasspath.
public void testClasspath() {
Classpath cp = (Classpath) subject.getClasspath().get(0);
assertTrue(cp.getId() != null && cp.getId().length() > 0);
assertTrue(cp.getArchive() != null && cp.getArchive().size() > 0);
ArchiveType archiveType = (ArchiveType) cp.getArchive().get(0);
assertTrue(archiveType.getPath() != null && archiveType.getPath().length() > 0);
}
use of org.eclipse.jst.server.generic.servertype.definition.Classpath in project webtools.servertools by eclipse.
the class GenericServerRuntime method validateClasspaths.
/**
* Checks all defined classpaths.
*/
protected IStatus validateClasspaths(ServerRuntime serverTypeDefinition) {
Iterator cpList = serverTypeDefinition.getClasspath().iterator();
while (cpList.hasNext()) {
Classpath cpth = (Classpath) cpList.next();
if (cpth.getArchive() == null || cpth.getArchive().size() < 1)
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, GenericServerCoreMessages.errorNoClasspath, null);
Iterator archIter = cpth.getArchive().iterator();
while (archIter.hasNext()) {
ArchiveType arch = (ArchiveType) archIter.next();
String arcPath = serverTypeDefinition.getResolver().resolveProperties(arch.getPath());
File f = new File(arcPath);
if (f.exists() == false)
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, NLS.bind(GenericServerCoreMessages.errorMissingClasspathEntry, f.getPath()), null);
}
}
// $NON-NLS-1$
return new Status(IStatus.OK, CorePlugin.PLUGIN_ID, 0, "", null);
}
Aggregations