use of org.eclipse.ceylon.cmr.api.ModuleDependencyInfo in project ceylon by eclipse.
the class ModuleVersionReader method getModuleVersionDetailsFromSource.
/**
* Reads a module descriptor and returns its information
* @param moduleName The name of the module
* @param srcDir The source directory where to find the descriptor
* @return A <code>ModuleVersionsDetails</code> with the encountered information
* @throws NoSuchModuleException if the module could not be found
*/
public static ModuleVersionDetails getModuleVersionDetailsFromSource(String moduleName, File srcDir) throws NoSuchModuleException {
ModuleDescriptorReader mdr = new ModuleDescriptorReader(moduleName, srcDir);
String module = mdr.getModuleName();
String version = mdr.getModuleVersion();
// PS In case the module descriptor was found but could not be parsed
// we'll create an invalid details object
ModuleVersionDetails mvd = new ModuleVersionDetails(module != null ? module : "", version != null ? version : "", mdr.getModuleGroupId(), mdr.getModuleArtifactId());
mvd.setLabel(mdr.getModuleLabel());
mvd.setLicense(mdr.getModuleLicense());
List<String> by = mdr.getModuleAuthors();
if (by != null) {
mvd.getAuthors().addAll(by);
}
SortedSet<ModuleDependencyInfo> dependencies = new TreeSet<>();
for (Object[] dep : mdr.getModuleImports()) {
dependencies.add(new ModuleDependencyInfo((String) dep[0], (String) dep[1], (String) dep[2], (Boolean) dep[3], (Boolean) dep[4], (Backends) dep[5]));
}
mvd.setDependencies(dependencies);
mvd.setRemote(false);
mvd.setOrigin("Local source folder");
return mvd;
}
use of org.eclipse.ceylon.cmr.api.ModuleDependencyInfo in project ceylon by eclipse.
the class AbstractTestTool method findTestVersionInDependecies.
private String findTestVersionInDependecies(ModuleDependencyInfo module, Queue<ModuleDependencyInfo> queue) {
Collection<ModuleVersionDetails> moduleDetailsCollection = getModuleVersions(module.getNamespace(), module.getName(), module.getVersion(), false, type, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
Iterator<ModuleVersionDetails> moduleDetailsIterator = moduleDetailsCollection.iterator();
if (moduleDetailsIterator.hasNext()) {
ModuleVersionDetails moduleDetails = moduleDetailsIterator.next();
for (ModuleDependencyInfo dependency : moduleDetails.getDependencies()) {
if (dependency.getName().equals("ceylon.test")) {
return dependency.getVersion();
}
if (dependency.getName().equals("ceylon.language")) {
continue;
}
queue.add(dependency);
}
}
return null;
}
use of org.eclipse.ceylon.cmr.api.ModuleDependencyInfo in project ceylon by eclipse.
the class AbstractCeylonArtifactResult method dependencies.
@Override
public List<ArtifactResult> dependencies() throws RepositoryException {
ModuleInfo infos = resolve();
// TODO -- perhaps null is not valid?
if (infos == null || infos.getDependencies().isEmpty())
return Collections.emptyList();
final List<ArtifactResult> results = new ArrayList<ArtifactResult>();
for (ModuleDependencyInfo mi : getOrderedDependencies(infos)) {
results.add(new LazyArtifactResult(manager, mi.getNamespace(), mi.getName(), mi.getVersion(), mi.isExport(), mi.isOptional(), mi.getModuleScope()));
}
return results;
}
use of org.eclipse.ceylon.cmr.api.ModuleDependencyInfo in project ceylon by eclipse.
the class BytecodeUtils method getDependencies.
private static Set<ModuleDependencyInfo> getDependencies(ClassFile moduleInfo, Object[] dependencies, String module, String version, String groupId, String artifactId, Overrides overrides) {
if (dependencies == null) {
return Collections.<ModuleDependencyInfo>emptySet();
}
int[] binver = getBinaryVersions(moduleInfo);
boolean supportsNamespaces = binver != null && ModuleUtil.supportsImportsWithNamespaces(binver[0], binver[1]);
Set<ModuleDependencyInfo> result = new HashSet<ModuleDependencyInfo>(dependencies.length);
for (Object depObject : dependencies) {
Annotation dep = (Annotation) depObject;
String namespace;
String modName = (String) ClassFileUtil.getAnnotationValue(moduleInfo, dep, "name");
if (supportsNamespaces) {
namespace = (String) ClassFileUtil.getAnnotationValue(moduleInfo, dep, "namespace");
if (namespace != null && namespace.isEmpty()) {
namespace = null;
}
} else {
if (ModuleUtil.isMavenModule(modName)) {
namespace = MavenRepository.NAMESPACE;
} else {
namespace = null;
}
}
String depVersion = (String) ClassFileUtil.getAnnotationValue(moduleInfo, dep, "version");
boolean export = asBoolean(moduleInfo, dep, "export");
boolean optional = asBoolean(moduleInfo, dep, "optional");
Backends backends = Backends.ANY;
Object[] backendNames = (Object[]) ClassFileUtil.getAnnotationValue(moduleInfo, dep, "dependencies");
if (backendNames != null) {
for (Object backend : backendNames) {
backends = backends.merged(Backend.fromAnnotation((String) backend));
}
}
result.add(new ModuleDependencyInfo(namespace, modName, depVersion, optional, export, backends));
}
if (overrides != null) {
result = overrides.applyOverrides(module, version, new ModuleInfo(null, module, version, groupId, artifactId, null, null, result)).getDependencies();
}
return result;
}
use of org.eclipse.ceylon.cmr.api.ModuleDependencyInfo in project ceylon by eclipse.
the class BytecodeUtils method matchesModuleInfo.
public boolean matchesModuleInfo(String moduleName, String moduleVersion, File moduleArchive, String query, Overrides overrides) {
ClassFile moduleInfo = readModuleInfo(moduleName, moduleArchive);
if (moduleInfo == null)
return false;
Annotation moduleAnnotation = ClassFileUtil.findAnnotation(moduleInfo, MODULE_ANNOTATION);
if (moduleAnnotation == null)
return false;
String groupId, artifactId;
groupId = (String) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "group");
if (groupId == null || groupId.isEmpty()) {
String[] coordinates = ModuleUtil.getMavenCoordinates(moduleName);
groupId = coordinates[0];
artifactId = coordinates[1];
} else {
artifactId = (String) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "artifact");
if (artifactId == null || artifactId.isEmpty())
artifactId = moduleName;
}
String version = (String) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "version");
if (version == null)
return false;
String doc = (String) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "doc");
if (doc != null && matches(doc, query))
return true;
String label = (String) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "label");
if (label != null && matches(label, query))
return true;
String license = (String) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "license");
if (license != null && matches(license, query))
return true;
Object[] by = (Object[]) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "by");
if (by != null) {
for (Object author : by) {
if (matches((String) author, query))
return true;
}
}
Object[] dependencies = (Object[]) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "dependencies");
if (dependencies != null) {
for (ModuleDependencyInfo dep : getDependencies(moduleInfo, dependencies, moduleName, version, groupId, artifactId, overrides)) {
if (matches(dep.getModuleName(), query))
return true;
}
}
return false;
}
Aggregations