use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class N4JSModel method getDependencies.
private ImmutableList<? extends IN4JSProject> getDependencies(N4JSProject project, boolean includeApis) {
ImmutableList.Builder<IN4JSProject> result = ImmutableList.builder();
URI location = project.getLocation();
ProjectDescription description = getProjectDescription(location);
if (description != null) {
result.addAll(resolveProjectReferences(project, description.getAllRequiredRuntimeLibraries()));
result.addAll(resolveProjectReferences(project, description.getAllProjectDependencies()));
result.addAll(getTestedProjects(project));
if (includeApis) {
result.addAll(resolveProjectReferences(project, description.getImplementedProjects()));
}
}
return result.build();
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class N4JSModel method getExtendedRuntimeEnvironment.
public Optional<IN4JSProject> getExtendedRuntimeEnvironment(N4JSProject project) {
final URI location = project.getLocation();
final ProjectDescription description = getProjectDescription(location);
if (null == description) {
return absent();
}
final ExtendedRuntimeEnvironment re = description.getExtendedRuntimeEnvironment();
if (null == re) {
return absent();
}
final ProjectReference ref = re.getExtendedRuntimeEnvironment();
return resolveProjectReference(project, ref);
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class FileBasedExternalPackageManager method loadManifest.
@Override
public ProjectDescription loadManifest(URI manifest) {
ResourceSet resourceSet = resourceSetProvider.get();
Resource resource = null;
try {
// in case the manifest does not exist, a (wrapped) FileNotFound is thrown
resource = resourceSet.getResource(manifest, true);
} catch (RuntimeException e) {
return null;
}
List<EObject> contents = resource.getContents();
if (contents.isEmpty() || !(contents.get(0) instanceof ProjectDescription)) {
return null;
}
// do some error handling:
if (!resource.getErrors().isEmpty()) {
throw new N4JSBrokenProjectException("Reading project description from " + manifest + " raised the following errors: " + Joiner.on('\n').join(resource.getErrors().stream().map(error -> error.getMessage() + " at line " + error.getLine()).iterator()));
}
ProjectDescription result = (ProjectDescription) contents.get(0);
contents.clear();
return result;
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class ExternalProjectProvider method getProjectsDescriptions.
Collection<ProjectDescription> getProjectsDescriptions(java.net.URI rootLocation) {
ensureInitialized();
File rootFolder = new File(rootLocation);
Set<ProjectDescription> projectsMapping = newHashSet();
URI rootUri = URI.createFileURI(rootFolder.getAbsolutePath());
for (Entry<URI, Optional<Pair<N4JSExternalProject, ProjectDescription>>> entry : projectCache.asMap().entrySet()) {
URI projectLocation = entry.getKey();
if (rootUri.equals(projectLocation.trimSegments(1))) {
Pair<N4JSExternalProject, ProjectDescription> pair = entry.getValue().orNull();
if (null != pair && null != pair.getFirst()) {
ProjectDescription description = pair.getSecond();
if (description != null) {
projectsMapping.add(description);
}
}
}
}
return unmodifiableCollection(projectsMapping);
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class ExternalProjectProvider method getProjectsIn.
Collection<N4JSExternalProject> getProjectsIn(java.net.URI rootLocation) {
ensureInitialized();
File rootFolder = new File(rootLocation);
Map<String, N4JSExternalProject> projectsMapping = newTreeMap();
URI rootUri = URI.createFileURI(rootFolder.getAbsolutePath());
for (Entry<URI, Optional<Pair<N4JSExternalProject, ProjectDescription>>> entry : projectCache.asMap().entrySet()) {
URI projectLocation = entry.getKey();
if (rootUri.equals(projectLocation.trimSegments(1))) {
Pair<N4JSExternalProject, ProjectDescription> pair = entry.getValue().orNull();
if (null != pair && null != pair.getFirst()) {
N4JSExternalProject project = pair.getFirst();
projectsMapping.put(project.getName(), project);
}
}
}
return unmodifiableCollection(projectsMapping.values());
}
Aggregations