use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class ExternalLibraryPreferencePage method getInstalledNpms.
private Map<String, String> getInstalledNpms() {
final URI root = installLocationProvider.getTargetPlatformNodeModulesLocation();
final Set<ProjectDescription> projects = from(externalLibraryWorkspace.getProjectsDescriptions((root))).toSet();
final Map<String, String> versionedNpms = new HashMap<>();
projects.forEach((ProjectDescription pd) -> {
versionedNpms.put(pd.getProjectId(), VersionConstraintFormatUtil.npmFormat(pd.getProjectVersion()));
});
return versionedNpms;
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class NpmPackageToProjectAdapter method adjustManifest.
/**
* Adjust manifests based on provided manifest fragments.
*
* @param manifest
* file to be adjusted
* @param manifestFragments
* that will be used to adjust the manifest
*/
private IStatus adjustManifest(final File manifest, final File... manifestFragments) {
if (Arrays2.isEmpty(manifestFragments)) {
// Nothing to merge.
return statusHelper.OK();
}
final URI manifestURI = URI.createFileURI(manifest.getAbsolutePath());
ProjectDescription pd = null;
for (int i = 0; i < manifestFragments.length; i++) {
File fragment = manifestFragments[i];
if (fragment.exists() && fragment.isFile()) {
URI manifestFragmentURI = URI.createFileURI(fragment.getAbsolutePath());
pd = manifestMerger.mergeContent(manifestFragmentURI, manifestURI);
fragment.delete();
} else {
LOGGER.warn("Broken manifest fragment: " + fragment + ".");
}
}
if (pd != null) {
ResourceSet resourceSet = resourceSetProvider.get();
Resource resource = resourceSet.getResource(manifestURI, true);
List<EObject> contents = resource.getContents();
contents.clear();
contents.add(pd);
try {
resource.save(null);
return statusHelper.OK();
} catch (IOException e) {
final String message = "Error while trying to write N4JS manifest content for: " + manifestURI + ".";
LOGGER.error(message, e);
return statusHelper.createError(message, e);
}
} else {
final String message = "Failed to merge N4JS manifest fragments into '" + manifestURI + "'.";
LOGGER.error(message);
return statusHelper.createError(message);
}
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class AbstractInternalWorkspaceTest method testGetLocation_04.
@SuppressWarnings("javadoc")
@Test
public void testGetLocation_04() {
ProjectDescription description = getWorkspace().getProjectDescription(myProjectURI);
ProjectDependency dependencyOnArchive = description.getAllProjectDependencies().get(0);
URI expectedToBeNull = getWorkspace().getLocation(myProjectURI, dependencyOnArchive, N4JSSourceContainerType.ARCHIVE);
assertNull(expectedToBeNull);
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class AbstractInternalWorkspaceTest method testDescriptionsAreSame.
@SuppressWarnings("javadoc")
@Test
public void testDescriptionsAreSame() {
ProjectDescription first = getWorkspace().getProjectDescription(myProjectURI);
ProjectDescription second = getWorkspace().getProjectDescription(myProjectURI);
assertSame(first, second);
}
use of org.eclipse.n4js.n4mf.ProjectDescription in project n4js by eclipse.
the class AbstractInternalWorkspaceTest method testGetProjectDescription_01.
@SuppressWarnings("javadoc")
@Test
public void testGetProjectDescription_01() {
ProjectDescription description = getWorkspace().getProjectDescription(myProjectURI);
assertNotNull(description);
assertEquals(myProjectId, description.getProjectId());
}
Aggregations