java - maven-jaxb2-plugin: How to use my own EqualsStrategy -
i'm using maven-jaxb2-plugin generate equals
, hashcode
methods.
i have implemented own strategies, derived jaxbequalsstrategy
, jaxbhashcodestrategy
.
is there way tell plugin use strategies instead of default ones?
e.g. via configuration like
<arg>-xequals=my.own.equalsstrategy</arg>
you correct:
<build> <defaultgoal>test</defaultgoal> <plugins> <plugin> <groupid>org.jvnet.jaxb2.maven2</groupid> <artifactid>maven-jaxb2-plugin</artifactid> <configuration> <extension>true</extension> <args> <arg>-xtostring</arg> <arg>-xequals</arg> <arg>-xequals-equalsstrategyclass=my.own.equalsstrategy</arg> <arg>-xhashcode</arg> <arg>-xhashcode-hashcodestrategyclass=my.own.hashcodestrategy</arg> </args> <plugins> <plugin> <groupid>org.jvnet.jaxb2_commons</groupid> <artifactid>jaxb2-basics</artifactid> </plugin> </plugins> </configuration> </plugin> </plugins> </build>
if strategies stateless (they should be), can create singleton instances public static final instance
fields in strategy classes. can include jar strategies configuration/plugins/plugin
(just add xjc classpath) , generated code use instance
fields instead of creating new instances of strategies.
disclaimer: i'm author of jaxb2 basics, jaxb plugin package in question.
Comments
Post a Comment