remove requires value from extension annotation and add new requires annotation instead

This commit is contained in:
Eduard Heimbuch
2020-04-07 12:49:25 +02:00
parent 3a6a41ac5b
commit 347417e247
9 changed files with 84 additions and 281 deletions

View File

@@ -101,6 +101,14 @@ public class ClassSetElement implements DescriptorElement
element.appendChild(attr);
}
if (c.requires != null) {
for (String requiresEntry : c.requires) {
Element requiresElement = doc.createElement("requires");
requiresElement.setTextContent(requiresEntry);
element.appendChild(requiresElement);
}
}
element.appendChild(classEl);
root.appendChild(element);
}
@@ -122,21 +130,24 @@ public class ClassSetElement implements DescriptorElement
/**
* Constructs ...
*
*
* @param className
* @param className
* @param description
* @param requires
* @param attributes
*/
public ClassWithAttributes(String className, String description,
Map<String, String> attributes)
String[] requires, Map<String, String> attributes)
{
this.className = className;
this.description = description;
this.requires = requires;
this.attributes = attributes;
}
//~--- fields -------------------------------------------------------------
private final String[] requires;
/** Field description */
private final Map<String, String> attributes;

View File

@@ -42,6 +42,7 @@ import org.xml.sax.SAXException;
import sonia.scm.annotation.ClassSetElement.ClassWithAttributes;
import sonia.scm.plugin.PluginAnnotation;
import sonia.scm.plugin.Requires;
//~--- JDK imports ------------------------------------------------------------
@@ -247,6 +248,14 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
if (isClassOrInterface(e)) {
TypeElement type = (TypeElement) e;
String[] requires = null;
Requires requiresAnnotation = type.getAnnotation(Requires.class);
if (requiresAnnotation != null) {
requires = requiresAnnotation.value();
}
String desc = processingEnv.getElementUtils().getDocComment(type);
if (desc != null) {
@@ -255,7 +264,7 @@ public final class ScmAnnotationProcessor extends AbstractProcessor {
classes.add(
new ClassWithAttributes(
type.getQualifiedName().toString(), desc, getAttributesFromAnnotation(e, annotation)
type.getQualifiedName().toString(), desc, requires, getAttributesFromAnnotation(e, annotation)
)
);
}