in uimafit-maven-plugin/src/main/java/org/apache/uima/fit/maven/EnhanceMojo.java [378:422]
private void enhanceResourceMetaData(JavaSource aAST, Class<?> aClazz, CtClass aCtClazz,
Multimap<String, String> aReportData) {
ClassFile classFile = aCtClazz.getClassFile();
ConstPool constPool = classFile.getConstPool();
AnnotationsAttribute annoAttr = (AnnotationsAttribute) classFile
.getAttribute(AnnotationsAttribute.visibleTag);
// Create annotation attribute if it does not exist
if (annoAttr == null) {
annoAttr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
}
// Create annotation if it does not exist
Annotation a = annoAttr.getAnnotation(ResourceMetaData.class.getName());
if (a == null) {
a = new Annotation(ResourceMetaData.class.getName(), constPool);
// Add a name, otherwise there will be none in the generated descriptor.
a.addMemberValue("name",
new StringMemberValue(ResourceMetaDataFactory.getDefaultName(aClazz), constPool));
}
// Update description from JavaDoc
String doc = Util.getComponentDocumentation(aAST, aClazz.getName());
enhanceMemberValue(a, "description", doc, overrideComponentDescription,
ResourceMetaDataFactory.getDefaultDescription(aClazz), constPool, aReportData, aClazz);
// Update version
enhanceMemberValue(a, "version", componentVersion, overrideComponentVersion,
ResourceMetaDataFactory.getDefaultVersion(aClazz), constPool, aReportData, aClazz);
// Update vendor
enhanceMemberValue(a, "vendor", componentVendor, overrideComponentVendor,
ResourceMetaDataFactory.getDefaultVendor(aClazz), constPool, aReportData, aClazz);
// Update copyright
enhanceMemberValue(a, "copyright", componentCopyright, overrideComponentCopyright,
ResourceMetaDataFactory.getDefaultCopyright(aClazz), constPool, aReportData, aClazz);
// Replace annotation
annoAttr.addAnnotation(a);
// Replace annotation attribute
classFile.addAttribute(annoAttr);
}