Bundle structure

A Telosys project may require a lot of templates, that's why the templates are organized in "bundles".

A "bundle" is just a set of "templates" (and sometimes resources) grouped together in a folder.

Thus it is possible to have clearly defined groups of templates for each part of the code to be generated (persistence, REST-API, DTO, HTML pages, testing, etc)

What's in a bundle ?

Each bundle folder contains:

  • 1 file "templates.cfg" (mandatory)

  • 1 file "README.md" (to provide information about the bundle, optional)

  • 1..N templates (Velocity ".vm" files)

  • 0..N resources files (static files)

  • any other useful file for the bundle

  • 0..N subfolders (to organize the different files)

The "templates.cfg" file

All code generation is driven by the "templates.cfg" file.

Each line of this file defines a genaration task with the necessary information:

  • the target file(s) to generate

  • the target directory in which to place the result

  • the template to use

  • the type of execution:

    • "*" : a code generation executed multiple times with the same template (1 generation for each selected entity)

    • "1" : a code generation executed only once independently of entities

    • "R" : a simple resources files copy in a destination folder (no template)

NB: if a template (".vm" file) is present in the bundle folder but not present in "templates.cfg", it will not be used.

Variables usable in "templates.cfg"

For greater flexibility, variables can be used in the target file name and the target directory name.

  • ${ENT} ⇒ current entity name (since ver 4.2.0 ) this variable is required for generation with type "*" in order to generate a file for each entity

  • ${BEANNAME} ⇒ same as ${ENT} deprecated since ver 4.2.0 ⇒ use ${ENT} instead

  • ${BUN} ⇒ current bundle name (since ver 4.2.0 )

  • ${MOD} ⇒ current model name (since ver 4.2.0 )

The following suffixes can be added to all of these variables:

  • "_LC" ⇒ conversion to "lower case". Examples: ${ENT_LC}, ${MOD_LC}

  • "_UC" ⇒ conversion to "upper case". Examples: ${ENT_UC}, ${MOD_UC}

It is also possible to use any variables defined in the project configuration:

  • standard predefined variables like ${SRC}, ${RES}, ${WEB}, ${TEST_SRC}, ${TEST_RES}, ${DOC}, ${TMP}

  • all other specific variables

How to customize a bundle?

Telosys was designed to allow users to customize code generation. So, if you reuse existing bundles, you will probably want to change some its parts.

What you can do:

  • modify existing templates (.vm files) with a text editor

  • add new templates (.vm files) in the bundle (don't forget to reference them in "templates.cfg")

  • delete certain templates (in this case you can only delete the line in "templates.cfg")

  • add new resources (static files) to be copied

How to use Git to clone and push a bundle ?

See Install with Git and Publish with Git

Last updated