Using Maven2 plugin

Maven2 plugin for allows user to generate class with entities as a part of build process controlled by Maven2.

Plugin is configured to be executed in generate-sources phase.

For description of goal see plugin documentation: version 1.0 or version 1.1-SNAPSHOT.

Generating code as a part of build process.

By default source is being generated into $ (in default setup it points to target/generated-sources/entities) directory. Plugin also adds this directory to list of directories containing source code, so this code is available for further processing (compilation). $ should not be stored in CVS/SVN.

Minimal pom.xml should contains:


where is a package name that should be used as a main package name for generated classes (generators adds a subpackage names to root name) and path/to/entities.dtd is a location of file containing entities.

Storing generated code in source repository

Plugin also may be used to generated source code stored in source code repository. For example of such configuration see samples in Mapping.