use of org.eclipse.ceylon.langtools.classfile.Annotation 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;
}
Aggregations