Reputation: 103
I am trying to add a @javax.annotation.Generated
annotation to all my classes generated by JAXB from a XSD.
I am using maven-jaxb2-plugin and a binding.xjb file to generate the source. I saw that the JAXB plugin jaxb2-basics-annotate should do the trick. But all I can find are examples that add annotations to specific classes. Like this one:
<jaxb:bindings schemaLocation="csw/2.0.2/CSW-discovery.xsd" node="/xs:schema">
<jaxb:bindings node="xs:complexType[@name='GetRecordsType']">
<annox:annotate>
<annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="GetRecordsType" />
</annox:annotate>
</jaxb:bindings>
How can I do this for each of my generated files? Is this possible at all?
Upvotes: 3
Views: 3032
Reputation: 46
It appears you are using highsource/jaxb2-annotate-plugin If you are also using his highsource/maven-jaxb2-plugin, there is builtin support for this feature. Just add this to the plugin configuration:
<configuration>
<markGenerated>true</markGenerated>
</configuration>
Also check controlling the output.
If you are the official jaxb2 plugin, that feature is also builtin
<configuration>
<addGeneratedAnnotation>true</addGeneratedAnnotation>
</configuration>
Upvotes: 3