TRIMM Java YAML configuration reference

Below is the reference for the TRIMM Java YAML configuration file.
A YAML that adheres to the specification below can be used directly with the TrimmJava Maven plugin.

Full YAML configuration file

# Setup
xmiModelPath: model/MDD Example.xml

# EA, MagicDraw16, MagicDraw17, FQCN, .groovy script
umlTool: EA

basePackageName: dk.tigerteam.mddexample
generateExtensionClasses: false

# addExtensionAndBaseClassAnnotations is only valid if generateExtensionClasses is set to true
addExtensionAndBaseClassAnnotations: false
modelPreprocessingScript: src/test/resources/model-preprocessing.groovy
collectionPropertyNameSuffix: Collection
    # Formatting exclusions can be specified even though implementation (above) hasn't been specified (and the default JalopyFormattingCodeWriter is used)
        - dk.tigerteam.mddexample.meta
        - dk.tigerteam.mddexample.test

# Paths
generateBaseClassesToPath: target/generated-sources/domainmodel
generateExtensionClassesToPath: src/main/domainmodel-extensions
generateInterfacesToPath: target/generated-sources/domainmodel
generateTestClassesToPath: target/generated-sources/generated-tests
generateResourcesToPath: target/generated-sources/generated-resources

    - name: DateTime
      javaType: org.joda.time.DateTime
    - name: LocalDate
      javaType: org.joda.time.LocalDate
    - name: TEXT
      javaType: java.lang.String

# Extensions (note these listeners can also be groovy scripts containing a single class implement the GeneratorEventListener interface (or which extend specializations thereof)
    - listener:
    - listener:
    - listener:
    - listener:
    - listener:
    - listener:
        property1: value1
        property2: value2
    - listener:
        propertyX: valueX
        propertyY: valueY

# Create Runtime Meta Model (is a requirement for createIntegrationTest)
    packageName: dk.tigerteam.mddexample.meta

Detailed explanation


Parameter Example value(s) Explanation
xmiModelPath model/MDD Example.xml The relative path to our XMI export file
  • EA – for Enterprise Architect 8.x and 9.x XMI 2.1 exports (as XML files)
  • MagicDraw16 for MagicDraw 16.x .xml and .mdzip files
  • MagicDraw17 for MagicDraw 17.x .xml and .mdzip files
  • Fully Qualified Class Name (FQCN) to a class on the classpath that implements the XmiReader interface
  • Path to a Groovy script file which contains a class that implements the XmiReader interface
Defines what XmiReader implementation to use.
Example of a custom EAXmiReader (here shown as Groovy code):

import dk.tigerteam.trimm.mdsd.uml2.xmi.ea.EAXmiReader

 * Example of using a Custom XMI Reader (in this case a 
 * specialization of EAXmiReader with its own XmiElement parsers)
class CustomEAXmiReader extends EAXmiReader {
    CustomEAXmiReader() {
        def parsers = [
            new EAXmiReader.PackageXmiElementParser(),
            new EAXmiReader.ClazzXmiElementParser(),
            new EAXmiReader.PropertyXmiElementParser(),
            new EAXmiReader.AssociationXmiElementParser(),
            new ExtendedEnumerationXmiElementParser(), // Our custom XmiElementParser
            new EAXmiReader.OperationXmiElementParser(),
            new EAXmiReader.ParameterXmiElementParser()

class ExtendedEnumerationXmiElementParser 
      extends EAXmiReader.EnumerationXmiElementParser {
basePackageName dk.tigerteam.mddexample This package will pre-appended all generated packages, classes, interfaces, etc. Since we export the model package in EA this means that our model classes will be generated into the package dk.tigerteam.mddexample
generateExtensionClasses false Means that we will NOT generate using the Generator Gap pattern. This basically means that any changes you the developer would make to the generated code will be overwritten next time the TRIMM Java plugin is run
addExtensionAndBaseClassAnnotations false If you set both generateExtensionClasses and addExtensionAndBaseClassAnnotations to true then TRIMM will insert a @BaseClazz in all Base classes and @ExtensionClazz in all Extension classes (see Generator Gap pattern for more information about Base and Extension Classes).
The @BaseClazz points towards the Extension class for the current class and the @ExtensionClazz points towards the Base class for the current Extension Class.

@BaseClazz(extensionClazz = Member.class)
public abstract class AbstractMember {
@ExtensionClazz(baseClazz = AbstractMember.class)
public class Member extends AbstractMember {

Note: You need to add a compiletime dependency to TrimmCore to compile the generated code – see

modelPreprocessingScript src/test/resources/model-preprocessing.groovy You can point to a Groovy script that allows you to preprocess the MetaModel before the code generation process begins.
The MetaModel is available as an implicit variable called metaModel

import dk.tigerteam.trimm.mdsd.meta.MetaClazz
import dk.tigerteam.trimm.mdsd.meta.MetaStereoType
import dk.tigerteam.trimm.mdsd.meta.MetaProperty

metaModel.each {  metaType ->
    // Swap Alias and Name in case there's an alias defined for a MetaType
	if (metaType.alias != null) {
		def old = = metaType.alias
		metaType.alias = old
    // Add a special property to the consultation class
    if ( == "Consultation") {
        def prop = new MetaProperty() = "mySpecialProperty"
        prop.type = new MetaClazz(String.class);
        prop.add(new MetaStereoType('Transient'))
        metaType.add prop
collectionPropertyNameSuffix Collection When TRIMM generated fields and properties for 1-to-Many and Many-to-Many associations (or attributes with cardinality Many) then you can specify a generic Suffix that will be added the field & property
sourceCodeFormatting Per default all code generated is formatted using the built in so you only need to specify this configuration parameter incase you need to exclude formatting for certain generated packages (e.g. for packages which contain Test classes or Runtime MetaModel classes – as they can tend to be quite large).
If you need to exclude formatting for certain packages you need to specify a sub-paramter called excludeFormattingForPackages and supply it with a list of package names:

        - dk.tigerteam.mddexample.meta
        - dk.tigerteam.mddexample.test
generateBaseClassesToPath target/generated-sources/domainmodel When generating without the Generator Gap pattern, then most classes generated (except interfaces) qualify as Base classes.
As can be seen, we generated to a java code subfolder of the target/generated-sources folder, which means that all generated code will be placed inside Mavens preferred location for intermediate code that isn’t checked into source control (which is recommended)
generateInterfacesToPath dk.tigerteam.trimm.examples.firstjpaproject Any interfaces generated are placed in this java code folder (same as above)
generateTestClassesToPath false Any test classes (i.e. code that doesn’t qualify as runtime code) gets generated to this java test code folder
generateResourcesToPath false Any resources (such as text files, xml, orm.xml, etc) gets generated to this resource folder


Parameter Value Explanation
name LocalDate The full name of an attribute/parameter type defined in the UML model
javaType org.joda.time.LocalDate Describes which Java class to use when (in this case) LocalDate is used in the UML model


Listener Explanation
BidirectionalGeneratorEventListener This listener will insert code into property accessors (e.g. getOrder() or getOrderLinesCollection()) that will ensure that associations that are defined as bi-directional in your UML also support that same in-memory (e.g. so customer.setAddress(address), will ensure that the generated code will call address.setCustomer(inverseCustomer) so that both customer and address have a pointer to each other in memory)
SerialVersionUIDGeneratorListener This listener will generate a private static final long serialVersionUID field in every generated class
PropertySugarMethodsEventListener This listener will generate fluent interface methods such as withXxxx or addToXxxxCollection properties
SomeListenerWhichNeedsParameters This listener (and the one below it) is an example of how a Listener can be configured using properties.
In this given example the SomeListenerWhichNeedsParameters has two properties called property1
and property2 which respectively gets set to value1 and value2.
What happens is that TRIMM instantiates SomeListenerWhichNeedsParameters using a default no-argument constructor and
afterwards calls setProperty1("value1") and setProperty2("value2") methods on the newly instantiated SomeListenerWhichNeedsParameters instance.


Parameter Value Explanation
packageName dk.tigerteam.trimm.examples.
This parameter control under which package the RuntimeMetaModel should be generated