use of org.eclipse.ceylon.cmr.api.ModuleInfo in project ceylon by eclipse.
the class OSGiDependencyResolver method parseRequireBundle.
private ModuleInfo parseRequireBundle(String requireBundle, String name, String version, Overrides overrides) {
Set<ModuleDependencyInfo> infos = new HashSet<>();
requireBundle = requireBundle.replaceAll(";bundle-version=\"\\[([^,]+),[^,]+(\\]|\\))\"", ";bundle-version=$1");
String[] bundles = requireBundle.split(",");
for (String bundle : bundles) {
infos.add(parseModuleInfo(bundle));
}
ModuleInfo ret = new ModuleInfo(null, name, version, // FIXME: does OSGi store this?
ModuleUtil.getMavenGroupIdIfMavenModule(name), ModuleUtil.getMavenArtifactIdIfMavenModule(name), ModuleUtil.getMavenClassifierIfMavenModule(name), null, infos);
if (overrides != null)
ret = overrides.applyOverrides(name, version, ret);
return ret;
}
use of org.eclipse.ceylon.cmr.api.ModuleInfo in project ceylon by eclipse.
the class BytecodeUtils method readModuleInformation.
/**
* Read module info from bytecode.
*
* @param moduleName the module name
* @param jarFile the module jar file
* @return module info list
*/
private static ModuleInfo readModuleInformation(final String moduleName, final File jarFile, Overrides overrides) {
ClassFile moduleInfo = readModuleInfo(moduleName, jarFile);
if (moduleInfo == null)
return null;
Annotation ai = ClassFileUtil.findAnnotation(moduleInfo, MODULE_ANNOTATION);
if (ai == null)
return null;
final String version = (String) ClassFileUtil.getAnnotationValue(moduleInfo, ai, "version");
if (version == null)
return null;
String groupId, artifactId;
groupId = (String) ClassFileUtil.getAnnotationValue(moduleInfo, ai, "group");
if (groupId == null || groupId.isEmpty()) {
String[] coordinates = ModuleUtil.getMavenCoordinates(moduleName);
groupId = coordinates[0];
artifactId = coordinates[1];
} else {
artifactId = (String) ClassFileUtil.getAnnotationValue(moduleInfo, ai, "artifact");
if (artifactId == null || artifactId.isEmpty())
artifactId = moduleName;
}
final Object[] dependencies = (Object[]) ClassFileUtil.getAnnotationValue(moduleInfo, ai, "dependencies");
final Set<ModuleDependencyInfo> infos = getDependencies(moduleInfo, dependencies, moduleName, version, groupId, artifactId, overrides);
ModuleInfo ret = new ModuleInfo(null, moduleName, version, groupId, artifactId, null, null, infos);
if (overrides != null)
ret = overrides.applyOverrides(moduleName, version, ret);
return ret;
}
use of org.eclipse.ceylon.cmr.api.ModuleInfo in project ceylon by eclipse.
the class AbstractCeylonArtifactResult method artifactId.
@Override
public String artifactId() {
ModuleInfo info = resolve();
if (info != null) {
String groupId = info.getGroupId();
String artifactId = info.getArtifactId();
if (groupId != null && !groupId.isEmpty()) {
if (artifactId != null && !artifactId.isEmpty())
return artifactId;
// if we have a group but not artifact, default to the entire name
return name();
}
}
return ModuleUtil.getMavenCoordinates(name())[1];
}
use of org.eclipse.ceylon.cmr.api.ModuleInfo in project ceylon by eclipse.
the class JSUtils method getModuleInfo.
private ModuleInfo getModuleInfo(Object obj, String moduleName, String version, Overrides overrides) {
if (obj == null) {
return new ModuleInfo(null, moduleName, version, null, null, null, null, Collections.<ModuleDependencyInfo>emptySet());
}
if (!(obj instanceof Iterable)) {
throw new RuntimeException("Expected something Iterable");
}
@SuppressWarnings("unchecked") Iterable<Object> array = (Iterable<Object>) obj;
Set<ModuleDependencyInfo> deps = new HashSet<ModuleDependencyInfo>();
for (Object o : array) {
String module;
boolean optional = false;
boolean exported = false;
if (o instanceof String) {
module = asString(o);
} else {
@SuppressWarnings("unchecked") Map<String, Object> m = (Map<String, Object>) o;
module = m.get("path").toString();
optional = m.containsKey("opt");
exported = m.containsKey("exp");
}
String depUri = ModuleUtil.moduleName(module);
String namespace = ModuleUtil.getNamespaceFromUri(depUri);
String modName = ModuleUtil.getModuleNameFromUri(depUri);
deps.add(new ModuleDependencyInfo(namespace, modName, ModuleUtil.moduleVersion(module), optional, exported, Backends.JS));
}
ModuleInfo result = new ModuleInfo(null, moduleName, version, null, null, null, null, deps);
if (overrides != null)
result = overrides.applyOverrides(moduleName, version, result);
return result;
}
use of org.eclipse.ceylon.cmr.api.ModuleInfo in project ceylon by eclipse.
the class JarUtils method readModuleInfo.
@Override
public ModuleVersionDetails readModuleInfo(String moduleName, String version, File moduleArchive, boolean includeMembers, Overrides overrides) {
ModuleInfo info = getDependencies(moduleArchive, moduleName, version, overrides);
ModuleVersionDetails mvd = new ModuleVersionDetails(moduleName, version, info != null ? info.getGroupId() : null, info != null ? info.getArtifactId() : null);
mvd.getArtifactTypes().add(new ModuleVersionArtifact(ArtifactContext.JAR, null, null));
if (info != null) {
mvd.getDependencies().addAll(info.getDependencies());
}
if (includeMembers) {
mvd.setMembers(getMembers(moduleArchive));
}
return mvd;
}
Aggregations