Adding Data Model Generation to a project
API Project
- Add directory src/main/dmgen with datamodel.xml and generator.xml
- Specify entities and their attributes in datamodel.xml
- Specify what the generator should do in generator.xml (in an API project usually generating dtos and joinDtos)#
Contents of generator.xml e.g.
In pom.xml: Add resources to build/resources section, e.g.:
In pom.xml: Register maven-clean plugin
In pom.xml: Register dmgen plugin
Impl Project
Add directory src/main/dmgen with only generator.xml (datamodel.xml will be copied from API project using the plugin calls shown below). Contents of generator.xml e.g.
In pom.xml: Add call to maven-clean-plugin
In pom.xml: Add call to maven-dependency-plugin
In pom.xml: Finally add call to dmgen-maven-plugin
Work around a battle between Eclipse and Maven:
Necessary dependencies (sql-util, jdbc2xml):
Subversion
- Refresh in Eclipse
- Delete all possibly (as result of testing the changes above) generated sources below src/generated/java. I.e. src/generated/java stays, but not src/generated/java/at.
- Commit the changes so far.
- Perform a maven build both on api and on impl project
- Refresh both projects in eclipse
- Both in api and in impl project, Team -> Add to svn.ignore by name the top level package below src/generated/java, e.g. "at".
- Commit.
Java Build Path
- In both projects (api and impl), add src/generated/java to the Build Path.
- Commit.