use of org.eclipse.ceylon.cmr.api.ModuleInfo 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.ModuleInfo 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.ModuleInfo in project ceylon by eclipse.
the class LegacyImporter method loadModuleDescriptor.
/**
* The descriptor to use, this can either be a <code>module.xml</code> or
* a <code>module.properties</code> file.
* If it exists it will be parsed and its contents used to determine which external
* classes are already covered by the defined dependencies.
* Regardless of whether the file exists it will be remembered for use with the
* <code>updateModuleDescripter()</code> method.
* @param descriptorFile
* @throws Exception
*/
public LegacyImporter loadModuleDescriptor() throws Exception {
if (descriptorFile != null && !descriptorLoaded) {
ModuleInfo moduleInfo = null;
if (descriptorFile.exists()) {
if (descriptorFile.toString().toLowerCase().endsWith(".xml")) {
moduleInfo = XmlDependencyResolver.INSTANCE.resolveFromFile(descriptorFile, moduleName, moduleVersion, lookupRepoman.getOverrides());
} else if (descriptorFile.toString().toLowerCase().endsWith(".properties")) {
moduleInfo = PropertiesDependencyResolver.INSTANCE.resolveFromFile(descriptorFile, moduleName, moduleVersion, lookupRepoman.getOverrides());
}
descriptorLoaded = true;
}
gatherExternalClasses(moduleInfo);
if (moduleInfo != null)
checkModuleDescriptor(moduleInfo);
}
return this;
}
use of org.eclipse.ceylon.cmr.api.ModuleInfo in project ceylon by eclipse.
the class URLContentStore method parseCompleteVersionsResponse.
protected void parseCompleteVersionsResponse(Parser p, ModuleVersionResult result, Overrides overrides) {
List<String> authors = new LinkedList<String>();
Set<ModuleDependencyInfo> dependencies = new HashSet<ModuleDependencyInfo>();
List<ModuleVersionArtifact> types = new LinkedList<ModuleVersionArtifact>();
p.moveToOpenTag("results");
while (p.moveToOptionalOpenTag("module-version")) {
String module = null, version = null, doc = null, license = null, label = null, groupId = null, artifactId = null;
authors.clear();
dependencies.clear();
types.clear();
while (p.moveToOptionalOpenTag()) {
if (p.isOpenTag("module")) {
// ignored
module = p.contents();
} else if (p.isOpenTag("version")) {
version = p.contents();
} else if (p.isOpenTag("doc")) {
doc = p.contents();
} else if (p.isOpenTag("groupId")) {
groupId = p.contents();
} else if (p.isOpenTag("artifactId")) {
artifactId = p.contents();
} else if (p.isOpenTag("license")) {
license = p.contents();
} else if (p.isOpenTag("label")) {
label = p.contents();
} else if (p.isOpenTag("authors")) {
authors.add(p.contents());
} else if (p.isOpenTag("dependency")) {
dependencies.add(parseDependency(p));
} else if (p.isOpenTag("artifact")) {
types.add(parseArtifact(p));
} else {
throw new RuntimeException("Unknown tag: " + p.tagName());
}
}
if (version == null || version.isEmpty())
throw new RuntimeException("Missing required version");
ModuleVersionDetails newVersion = result.addVersion(null, module, version);
if (newVersion != null) {
if (groupId != null && !groupId.isEmpty())
newVersion.setGroupId(groupId);
if (artifactId != null && !artifactId.isEmpty())
newVersion.setArtifactId(artifactId);
if (doc != null && !doc.isEmpty())
newVersion.setDoc(doc);
if (license != null && !license.isEmpty())
newVersion.setLicense(license);
if (label != null && !label.isEmpty())
newVersion.setLabel(label);
if (!authors.isEmpty())
newVersion.getAuthors().addAll(authors);
if (overrides != null) {
final ModuleInfo info = new ModuleInfo(null, module, version, groupId, artifactId, null, null, dependencies);
dependencies = overrides.applyOverrides(module, version, info).getDependencies();
}
if (!dependencies.isEmpty())
newVersion.getDependencies().addAll(dependencies);
if (!types.isEmpty())
newVersion.getArtifactTypes().addAll(types);
newVersion.setRemote(true);
if (isHerd()) {
newVersion.setOrigin(HERD_ORIGIN + " (" + getDisplayString() + ")");
} else {
newVersion.setOrigin(getDisplayString());
}
}
p.checkCloseTag();
}
p.checkCloseTag();
}
use of org.eclipse.ceylon.cmr.api.ModuleInfo in project ceylon by eclipse.
the class MavenDependencyResolver method toModuleInfo.
private static ModuleInfo toModuleInfo(DependencyDescriptor descriptor, String name, String version, Overrides overrides) {
Set<ModuleDependencyInfo> infos = new HashSet<>();
for (DependencyDescriptor dep : descriptor.getDependencies()) {
String depName = MavenUtils.moduleName(dep.getGroupId(), dep.getArtifactId(), null);
infos.add(new ModuleDependencyInfo(MavenRepository.NAMESPACE, depName, dep.getVersion(), dep.isOptional(), false, Backends.JAVA, AetherUtils.toModuleScope(dep)));
}
String descrName = MavenUtils.moduleName(descriptor.getGroupId(), descriptor.getArtifactId(), null);
// if it's not the descriptor we wanted, let's not return it
if (name != null && !name.equals(descrName))
return null;
if (version != null && !version.equals(descriptor.getVersion()))
return null;
ModuleInfo ret = new ModuleInfo(MavenRepository.NAMESPACE, descrName, descriptor.getVersion(), descriptor.getGroupId(), descriptor.getArtifactId(), null, null, infos);
if (overrides != null)
ret = overrides.applyOverrides(descrName, descriptor.getVersion(), ret);
return ret;
}
Aggregations