Generate Source Code

Home > Model Transformation > Model-to-Text (M2T) > OOMEGA Generator > Generate Source Code

You can now start to generate the desired source code. The command line arguments of org.oomega.generator.JGen specify a target, the model repository, which of your metamodels should be computed and a destination directory for the resulting source code files.

<java classname   = "org.oomega.generator.JGen"
      fork        = "true"
      failonerror = "true"
      classpath   = "etc:${oomega.home}/lib/oomega-generator.jar:${oomega.home}/lib/oomega-core.jar:build/temp/templates">
   <arg line = "-target hibernate" />
   <arg line = "-model:file model/" />
   <arg line = "-select:metamodel all" />
   <arg line = "-dest:dir build/temp/generate/model-classes" />
</java>

For a convenient usage within Ant environments, we provide a particular Ant-Task <jgen>, as well. To make the OOMEGA Ant-Tasks available you use the same statement we introduced in the chapter Compile Templates. Using the OOMEGA Ant-Task, code generation is done as follows:

<jgen templatepath="build/temp/templates/">
   <target name = "hibernate" />
   <model  file = "model/" />
   <select metamodel = "all" />
   <dest   dir = "build/temp/generate/model-classes" />
</jgen>

Next chapter: OOMEGA oAW

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.