Using XVisitor with Maven

Using XVisitor with Maven

The preferred way of using XVisitor in your builds is in combination with the Maven JAXB2 plugin. Here is an example from the xvisitor-docbook integration test:

<build> <plugins> <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.8.0</version> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <extension>true</extension> <args> <arg>-Xvisitor</arg> <arg>-Xvisitor-package:org.ops4j.xvisitor.docbook.jaxb.visitor</arg> </args> <generatePackage>org.ops4j.xvisitor.docbook.jaxb</generatePackage> <schemaIncludes> <include>xsd/docbook.xsd</include> </schemaIncludes> <bindingIncludes> <include>xjb/docbook.xjb.xml</include> </bindingIncludes> <plugins> <plugin> <groupId>org.ops4j.xvisitor</groupId> <artifactId>xvisitor-plugin</artifactId> <version>0.1.0</version> </plugin> </plugins> </configuration> </plugin> </plugins> </build>

The mandatory -Xvisitor argument enables the XVisitor plugin.

The optional -Xvisitor-package argument defines a package name for the additional classes generated by XVisitor. By default, this is the package of the other generated classes which is set in the <generatePackage> element.

Make sure to configure the xvisitor-plugin in the <plugins> section of the Maven JAXB2 plugin.