Customizing code generation

If you need to customize the generated code, simply provide custom templates to the JOMC Ant Tasks. This is done by adding a template artifact to the classpath of the tasks and setting the templateProfile parameter of the various tasks. As a starting point you can copy the default templates from the JOMC Tools artifact from directory org/jomc/tools/templates/jomc-java to a org/jomc/tools/templates/sub-directory of your template artifact.

For example, copying the default templates to directory org/jomc/tools/templates/custom-profile, you need to set the templateProfile parameter to custom-profile and add your template artifact to the classpath of the tasks for the templates to be found.

See class SourceFileProcessor for details, especially the getVelocityTemplate method and the getSourceFilesType methods.

Controlling behaviour of the default templates

The behaviour of the default templates can be controlled using templateParameter nested elements. The default values are shown below.

<!-- Flag indicating generated code to contain checks for illegal null references using the 'assert' keyword. -->
<templateParameter key="with-assertions" value="true" type="java.lang.Boolean"/>

<!-- Flag indicating generated code to contain copyright notices based on model object authors. -->
<templateParameter key="with-author-copyright" value="true" type="java.lang.Boolean"/>

<!-- Flag indicating generated code to contain editor folds for the Netbeans IDE and compatible editors. -->
<templateParameter key="with-editor-fold" value="true" type="java.lang.Boolean"/>

<!-- Flag indicating generated code to contain javadoc documentation. -->
<templateParameter key="with-javadoc" value="true" type="java.lang.Boolean"/>

<!-- Flag indicating generated code to contain '@author' javadoc documentation tags. -->
<templateParameter key="with-javadoc-author" value="true" type="java.lang.Boolean"/>

<!-- Flag indicating generated code to contain '@version' javadoc documentation tags. -->
<templateParameter key="with-javadoc-version" value="true" type="java.lang.Boolean"/>

<!-- Flag indicating generated code to contain JSR-250 '@Generated' annotations. -->
<templateParameter key="with-jsr-250" value="true" type="java.lang.Boolean"/>

<!-- Name of the project. -->
<templateParameter key="with-project-name"/>

<!-- SCM file identification keyword. The given value will be surrounded by '$' characters. -->
<templateParameter key="with-revision-keyword" value="Id"/>

<!-- Since 1.3: Flag indicating generated code to contain '@SuppressWarnings' annotations with the given value.  -->
<templateParameter key="with-suppress-warnings" value="&quot;unused&quot;"/>

<!-- Flag indicating generated code to contain copyright notices based on model object vendor information. -->
<templateParameter key="with-vendor-copyright" value="true" type="java.lang.Boolean"/>