Skip to Content
0
Mar 17 at 10:49 AM

Bean generation with custom annotations

218 Views Last edit Mar 17 at 10:51 AM 3 rev

I have generated an extension and wrote some functionality to leverage exporting of data.
The export functionality is based on custom annotations.

The objects' classes to be exported are generated via extension-beans.xml.
So the bean definition looks like this

<bean class="path.to.my.Bean">
<import type="path.to.my.custom.Annotation1" />
<import type="path.to.my.custom.Annotation2"/>
<annotations>@Annotation1(value = "somevalue")</annotations>
<property name="field1" type="String">
<annotations>@Annotation2(value = "somevalue")</annotations>
</property>
<property name="field2" type="String">
<annotations>@Annotation1(value = "someothervalue")</annotations>
</property><br></bean>

The extension where the bean is defined has `<requires-extension name="myextension" />` in its extensioninfo.xml defined and this seems to work.

When running ant all now I get an error with @Annotation1 cannot be resolved to a type.

Question now is, how can I get my custom annotations to be recognized by the generated classes.

Additionally, this is one of my custom annotations

@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Annotation1 {
String value(); }


I'm running v2105.15 with Java 11