The Maven Schema Generation Plugin turns the schema definition into a Java class. It happens all automagically, as long as the plugin is in your project's POM file. You may just use the following code and paste it in your POM, but do not forget to add the reference(s) to your schema(s).
<project> ... <build> <plugins> <plugin> <groupId>net.sf.tabletools</groupId> <artifactId>maven-schema-generation-plugin</artifactId> <version>${releaseVersion}</version> <configuration> <xmlSchemas> <!-- Add the path to your schema(s) here. --> <!-- <param>path/to/schema.xml</param> --> </xmlSchemas> </configuration> <executions> <execution> <phase>generate-sources</phase> <goals><goal>generate-schema</goal></goals> </execution> </executions> </plugin> </plugins> </build> <pluginRepositories> <pluginRepository> <id>tabletools.sourceforge.net</id> <name>TableTools Repository</name> <url>http://downloads.sourceforge.net/project/tabletools/m2repo</url> </pluginRepository> </pluginRepositories> </project>
The magic happens during the generate-sources lifecycle phase, which is near the beginning of the build lifecycle. This means that it is implied by most targets, such as compile and package. Should you want to invoke source generation explicitly, just run
mvn generate-sources
Also note the pluginRepository section, which points Maven to the TableTools repository to fetch the Schema Generation Plugin when necessary.