use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class EclipseBasedN4JSWorkspace method loadManifest.
ProjectDescription loadManifest(URI manifest) {
try {
ProjectDescription result = null;
ResourceSet resourceSet = resourceSetProvider.get(null);
String platformPath = manifest.toPlatformString(true);
if (manifest.isArchive() || platformPath != null) {
if (manifest.isArchive() || workspace.getFile(new Path(platformPath)).exists()) {
Resource resource = resourceSet.getResource(manifest, true);
if (resource != null) {
List<EObject> contents = resource.getContents();
if (contents.isEmpty() || !(contents.get(0) instanceof ProjectDescription)) {
return null;
}
result = (ProjectDescription) contents.get(0);
contents.clear();
}
}
}
return result;
} catch (WrappedException e) {
throw new IllegalStateException("Unexpected manifest URI: " + manifest, e);
}
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class ExternalProjectCacheLoader method load.
@Override
public Optional<Pair<N4JSExternalProject, ProjectDescription>> load(final URI rootLocation) throws Exception {
ProjectDescription projectDescription = packageManager.loadManifestFromProjectRoot(rootLocation);
if (null != projectDescription) {
File projectRoot = new File(rootLocation.toFileString());
ExternalProject p = new ExternalProject(projectRoot, NATURE_ID, BUILDER_ID);
IN4JSProject pp = new N4JSEclipseProject(p, rootLocation, model);
N4JSExternalProject ppp = new N4JSExternalProject(projectRoot, pp);
return Optional.of(Tuples.create(ppp, projectDescription));
}
return Optional.absent();
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class EclipseExternalLibraryWorkspace method getLocation.
@Override
public URI getLocation(URI projectURI, ProjectReference reference, N4JSSourceContainerType expectedN4JSSourceContainerType) {
if (PROJECT.equals(expectedN4JSSourceContainerType)) {
String name = reference.getProject().getProjectId();
ExternalProject project = projectProvider.getProject(name);
if (null == project) {
return null;
}
File referencedProject = new File(project.getLocationURI());
URI refLocation = URI.createFileURI(referencedProject.getAbsolutePath());
Pair<N4JSExternalProject, ProjectDescription> pair = projectProvider.getProjectWithDescription(refLocation);
if (null != pair) {
return refLocation;
}
}
return null;
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class DependenciesHelper method getAvailableProjectsDescriptions.
private Iterable<ProjectDescription> getAvailableProjectsDescriptions(List<File> allProjectsRoots) {
List<ProjectDescription> descriptions = new ArrayList<>();
allProjectsRoots.forEach(root -> {
File manifest = new File(root, IN4JSProject.N4MF_MANIFEST);
if (!manifest.isFile()) {
System.out.println("Cannot read manifest at " + root);
return;
}
ProjectDescription projectDescription = ProjectDescriptionProviderUtil.getFromFile(manifest);
descriptions.add(projectDescription);
});
return descriptions;
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class N4JSModel method getExtendedRuntimeEnvironmentName.
public Optional<String> getExtendedRuntimeEnvironmentName(URI location) {
if (null == location) {
return absent();
}
final ProjectDescription description = getProjectDescription(location);
if (null == description) {
return absent();
}
final ExtendedRuntimeEnvironment extendedRe = description.getExtendedRuntimeEnvironment();
if (null == extendedRe) {
return absent();
}
final ProjectReference reRef = extendedRe.getExtendedRuntimeEnvironment();
if (null == reRef) {
return absent();
}
final SimpleProjectDescription project = reRef.getProject();
if (null == project) {
return absent();
}
return fromNullable(project.getProjectId());
}
Aggregations