use of org.eclipse.ceylon.langtools.classfile.ClassFile in project ceylon by eclipse.
the class BytecodeUtils method readModuleInfo.
@Override
public ModuleVersionDetails readModuleInfo(String moduleName, String moduleVersion, File moduleArchive, boolean includeMembers, Overrides overrides) {
ClassFile moduleInfo = readModuleInfo(moduleName, moduleArchive);
if (moduleInfo == null)
return null;
Annotation moduleAnnotation = ClassFileUtil.findAnnotation(moduleInfo, MODULE_ANNOTATION);
if (moduleAnnotation == null)
return null;
String doc = (String) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "doc");
String license = (String) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "license");
String label = (String) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "label");
Object[] by = (Object[]) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "by");
Object[] dependencies = (Object[]) ClassFileUtil.getAnnotationValue(moduleInfo, moduleAnnotation, "dependencies");
String type = ArtifactContext.getSuffixFromFilename(moduleArchive.getName());
int[] binver = getBinaryVersions(moduleInfo);
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;
}
ModuleVersionDetails mvd = new ModuleVersionDetails(moduleName, getVersionFromFilename(moduleName, moduleArchive.getName()), groupId, artifactId);
mvd.setDoc(doc);
mvd.setLabel(label);
mvd.setLicense(license);
if (by != null) {
for (Object author : by) {
mvd.getAuthors().add((String) author);
}
}
mvd.getDependencies().addAll(getDependencies(moduleInfo, dependencies, moduleName, mvd.getVersion(), groupId, artifactId, overrides));
ModuleVersionArtifact mva = new ModuleVersionArtifact(type, binver[0], binver[1]);
mvd.getArtifactTypes().add(mva);
if (includeMembers) {
mvd.setMembers(getMembers(moduleArchive));
}
return mvd;
}
use of org.eclipse.ceylon.langtools.classfile.ClassFile 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