Maven Integration

JEAF Generator is provided as Maven Plugin and thus can be easily integrated into your build process.

 

This side will describe how to do that:

Preconditions

As described in Maven Build Helper Plugin when working with JEAF or JEAF Generator then we need to make use of Maven Build Helper Plugin. So please refer to the mentioned site to ensure that is integrated properly.

Maven Plugin Configuration Parameters

The following tables describe all possible configuration parameters of the JEAF Generator Maven Plugin. Usage of almost all of them is shown in the example below.

Common Configuration Parameters

Configuration Parameter

Required / Optional / Default

Description

Configuration Parameter

Required / Optional / Default

Description

modelArtifactGroupID

The UML model can either be defined by pointing to the directory where the XMI files are located directly or by referencing an artifact that contains the XMI files. In case artifact referencing also a dependency to the artifact is required (see example below)

The parameters are required in case of artifact referencing. For further details please also refer to Export UML Model from MagicDraw UML

Group ID of the artifact that contains the XMI files of the UML model.

modelArtifactArtifactID

Artifact ID of the artifact that contains the XMI files of the UML model.

modelArtifactXMIPath

XMI Path inside the artifact that contains the XMI files of the UML model.

xmiDirectory

Parameter is required in case of directly pointing to XMI files.

Directory which contains all XMI files. The files have to be exported from MagicDraw UML using its Eclipse UML2 Export v2.x

umlModelFile

Parameter is optional for case that JEAF Generator only should generate so called message constants. In this case no UML model is required as input. For further details please also refer to Internationalization / Localization

Name of the model file that should be used. Usually it has the same name as the MagicDraw UML project. Only the name of the file has to be provided as we assume that the file is located in the XMI directory.

 

umlProfileFile

Name of the file that contains the JEAF Meta Model (JMM). Usually the default value "JMM.profile.uml" can be used. Only the name of the file has to be provided as we assume that the file is located in the XMI directory.

sourceDirectory

required in case of code generation from UML models but not for message constants only.

Directory where all files that belong to the src slot will be written to. Files in this directory will not be overwritten.

sourceGenDirectory

required

Directory where all files that belong to the src-gen slot will be written to. Content of this directory will be overwritten every time JEAF Generator will be executed.

resourceDirectory

required

Directory where all files that belong to the res slot will be written to. Files in this directory will not be overwritten.

resourceGenDirectory

required

Directory where all files that belong to the res-gen slot will be written to. Content of this directory will be overwritten every time JEAF Generator will be executed.

cleanSourceGen

optional

Parameter defines if src-gen slot should be cleaned before the generator runs. Cleaning means that all existing files will be deleted. Cleaning src-gen slot is the proposed way to go.

By default it is disabled.

cleanResourceGen

optional

Parameter defines if res-gen slot should be cleaned before the generator runs. Cleaning means that all existing files will be deleted. Cleaning res-gen slot is the proposed way to go.

By default it is disabled.

umlModelingTool

MAGIC_DRAW

Besides MagicDrawUML JEAF Generator also supports Eclipse Papyrus as modeling tool (ECLIPSE_PAPYRUS). Using this parameter the modeling tool can be configured.

enterpriseJavaType

JAVA_EE

Parameter defines the type of Enterprise Java that should be used for code generation. By default JavaEE (aka JEE) is used.

Using this parameter the Enterprise Java type can be configured. For backward compatibgility reasons default value is still JavaEE (aka JEE). However, usage of Jakarta EE (JAKARTA_EE) is strongly recommended.

customRootTemplate

CustomRoot::Root
optional

Name of the root template for customer specific extensions

customCheckFiles

optional

List of custom check files that will be used to run customer specific checks of the UML model.

packages

required in case of code generation from UML models but not for message constants only.

Whitelist of packages for the JEAF Generator. Model elements of all packages that match with the white list will be handled by JEAF Generator.

ignoredResourceFiles

optional

List of resource files that should be ignored when generating message constants classes from resource files.

fileHeaderCompany

optional

Company information for header of generated files.

fileHeaderAuthor

optional

Author information for header of generated files.

fileHeaderCopyright

optional

Copyright information for header of generated files.

fileHeaderVersion

optional

Version information for header of generated files.

disableFormatting

false

Parameter can be used to disable formatting of generated sources and resources in general.

disableSourceFormatting

false

Parameter can be used to disable formatting of generated sources only.

disableResourceFormatting

false

Parameter can be used to disable formatting of generated resources only.

javaFormatterStyleFile

optional

Reference to the file that contains the code style definition for Java code. If it is not defined then the default code style will be used.

xmlFormatterStyleFile

optional

Reference to the file that contains the code style definition for XML. If it is not defined then the default code style will be used.

importGroups

java.,javax.,org.,com.

Parameter defines the grouping and sorting of Java import statements.

staticImportGroups

java,*

Parameter defines the grouping and sorting of static Java import statements.

generateEqualsAndHashCode

false

Switch defines if equals() and hashCode() should be generated for all variants of model elements with stereotypes «POJO» and «ServiceObject».

generateEqualsAndHashCodeForStandardClasses

false

Switch defines if equals() and hashCode() should be generated for “normal“ model elements with stereotypes «POJO» and «ServiceObject».

generateEqualsAndHashCodeForCompositeDataTypes

false

Switch defines if equals() and hashCode() should be generated for composite data type model elements with stereotypes «POJO» and «ServiceObject».

generateEqualsAndHashCodeForOpenAPIDataTypes

false

Switch defines if equals() and hashCode() should be generated for «OpenAPIDataType» model elements with stereotypes «POJO» and «ServiceObject».

makePOJOsSerializable

false

Switch defines whether POJO's should be serializable or not.

generateHeavyExtensibleEnums

false

Switch defines if extensible enums should be generated in light-weight or heavy-weight style.

By default to so called light-weight style is used where extensible enums will have an additional literal UNKNOWN.

generateImmutableClasses

false

Switch defines whether generated «POJO» and / or «ServiceObject» should be immutable. This switch is set to true then it will overrule settings from the UML model (Flag readonly for properties).

generateValidAnnotationForAssociations

false

Switch defines if Java Validation Annotation @Valid will be generated for all references classes with stereotypes «POJO», «ServiceObject», «DomainObject» or «PersistentObject» even in cases when it is not defined in the UML model.

generateValidationAnnotationsForAttributesFromMultiplicity

false

Switch defines whether Java Validation Annotations should not only be generated for explicitly modeled annotations but also from multiplicity of modeled attributes.

generateValidationAnnotationsForAssociationsFromMultiplicity

false

Switch defines whether Java Validation Annotations should not only be generated for explicitly modeled annotations but also from multiplicity of modeled associations.

generateObjectValidationInBuilder

false

Switch defines if object validation should be generated in build() operation of the class builder. If it is enabled then the generated code will have a dependency on one of the following artifacts:

Spring Boot:

<dependency> <groupId>com.anaptecs.jeaf.validation</groupId> <artifactId>jeaf-validation-api-spring</artifactId> <version>${1.6.0 or higher}</version> </dependency>

JEAF:

<dependency> <groupId>com.anaptecs.jeaf.validation</groupId> <artifactId>jeaf-validation-api-service-provider</artifactId> <version>${1.6.0 or higher}</version> </dependency>

Depending on the implementation of class com.anaptecs.jeaf.validation.api.ValidationExecutor if might still be possible to disable / enable request validation without changing the code.

generateOfOperation

false

Switch defines if an of(...) operation should be generated for «POJO» or «ServiceObject». This switch does not have any impact on «POJO» or «ServiceObject» taht are also modelled as so called «OpenAPIDataType». Instead please use configured parameter generateValueOfForOpenAPIDataTypes.

Which properties will be used for the of(...) operation depends on the settings in UML model and the configured default mode

generateOfOperationForOpenAPIDataType

false

Switch defines if an of(...) operation should be generated for OpenAPI Data Types. This switch does not have any impact on so standard «POJO» / «ServiceObject». For them no of(...) operation will be generated. Instead please use configured parameter generateOfOperation.

generateValueOfForOpenAPIDataTypes

false

Switch defines whether for the Java representation of OpenAPI Data Types as valueOf(...) method should be generated or not. If this is required depends on the framework that is used for your REST implementation. Currently (Spring Boot 2.7.* and Jersey 2.35) it is only required in case of Jersey. Default Spring Boot REST implementation does not require that.

generateBuilderWithAllMandatoryFields

false

Switch enables that JEAF Generator generates a builder(...) method that directly contains all mandatory fields.

javaGenericSoftLinkType

 

When working with soft links in your UML model then you can define there that a custom generic type should be used for the soft link. The concrete java type (its fully qualified class name) that should be used can be defined through this parameter.

generatePublicSettersForAssociations

false

Switch defines whether the generated set methods for one-to-many associations should be public or not.

generateNullChecksForToOneAssociations

false

Switch defines whether the generated set methods for to-one associations has checks for null values of parameters.

disableImmutabilityOfCollections

false

Switch defines whether generated methods dealing with any kind of collections must ensure that the internal state of an object can not be modified by accident. This will lead to get method that make use of Collections.unmodifiableCollection(...).

Builders that receive a collection as input will copy their content. This is the default behavior of JEAF Generator. If this parameter is set to true then this means that collections returned from a get method may also be modified from the outside.

disableImmutabilityOfArrays

false

Switch defines whether generated methods dealing with arrays must ensure that the internal state of an object can not be modified by accident. This will lead to System.arraycopy(...) in get methods.

Builders that receive an array as input will copy their content. This is the default behavior of JEAF Generator. If this parameter is set to true then this means that arrays return from get method can directly be modified and this will also impact the state of the object were the array belongs to.

disableImmutabilityOfBinaryData

false

Switch defines whether generated methods dealing with byte arrays must ensure that the internal state of an object can not be modified by accident. This will lead to System.arraycopy(...) in get methods. Builders that receive an array as input will copy their content. This is the default behavior of JEAF Generator. If this parameter is set to true then this means that arrays return from get method can directly be modified and this will also impact the state of the object were the array belongs to.

generatePublicObjectView

false

Switch defines if only the public view of POJO's or ServiceObjects should be generated. This will lead to generated classes where some internal structures of a POJO / ServiceObject will be hidden to the outside world.

enableDetailedToStringMethod

false

Switch defines if a detailed toString() method should be generated for POJOs, ServiceObjects and DomainObjects. "Detailed" here means that besides the attributes of an class also references to other objects and arrays with be present in result of toString().

enableSemVerForJSON

true

Parameter defines if generated code for JSON serialization / deserialization should be SemVer compliant, which is strongly recommend. If parameter is set to true then generated code will ignore unknown properties in read JSON and just ignore them.

generateJAXRSAnnotations

false

Parameter defines if JAX-RS annotations for service objects or POJOs should be generated. If the parameter is set to true then the generated code will make us of JAX-RS annotations. This means that your project also needs to define a dependency to a JAR containing them (e.g. JavaEE API)

generateJacksonAnnotations

false

Parameter defines if Jackson annotations for service objects or POJOs should be generated. If the parameter is set to true then the generated code will make us of Jackson annotations. Jacksons annotations are required if you want to make use of Jackson JSON serialization. This means that your project also needs to define a dependency to a JAR containing them (e.g. Jackson Databind)

suppressWarnings

 

Parameter can be used to define a list of warning that should be suppressed in the generated code. This will lead to annotation @SuppressWarnings for the defined warnings

suppressAllWarnings

false

Parameter can be used to suppress all warnings in generated code @SuppressWarnings("all").

It's strongly recommended to not use this feature ;-)

breakBuildOnGeneratorError

true

Switch defines if errors during code generation should break the build. This feature is mainly intended for test purposes of JEAF Generator itself.

addGeneratedAnnotation

false

Parameter can be used to add @Generated annotation to generated code.

addGenerationTimestamp

false

Parameter can be used to also add timestamp of code generation to the @Generated annotation. Parameter is only relevant if addGeneratorAnnotation is set to true.

generationComment

 

Parameter can be used to also add the defined comment of code generation to the @Generated annotation. Parameter is only relevant if addGeneratorAnnotation is set to true.

targetRuntime

JEAF

Parameter can be used to define the target runtime environment for which code should be generated. Currently JEAF, Spring and Java are supported. Valid values are : JEAF, SPRING, JAVA

restLibrary

 

REST Library that is the target for code generation. Depending on the target runtime either JAX-RS (Java and JEAF) or Spring Web MVC (Spring) is used as default.

Supported values are: JAX_RS, SPRING_WEB_MVC

 

Configuration Parameters for Services / REST Resources

Configuration Parameter

Required / Optional / Default

Description

Configuration Parameter

Required / Optional / Default

Description

generateServiceObjects

false

Switch defines whether service objects should be generated or not.

generateServiceInterfaces

false

Switch defines whether service interfaces should be generated or not.

generateServiceProxies

false

Switch defines whether service proxies should be generated or not.

generateRESTResources

false

Switch defines whether REST resources should be generated or not.

generateSecurityAnnotation

false

Switch defines if target runtime specific security annotations (e.g. @RolesAllowed from JSR-250 or @PreAuthorize from Spring Security) should be generated or not.

useDeprecatedSpringSecuredAnnotation

false

Switch defines if in case of Spring deprecated @Secured annotation should be used instead of recommended @PreAuthorize.

generateRESTRequestValidation

false

Switch defines if request validation for REST Resources / Controllers or REST Clients (aka REST Service Proxies) should be generated. If it is enabled then the generated code will have a dependency on one of the following artifacts:

Spring Boot:

<dependency> <groupId>com.anaptecs.jeaf.validation</groupId> <artifactId>jeaf-validation-api-spring</artifactId> <version>${1.6.0 or higher}</version> </dependency>

JEAF:

Depending on the implementation of class com.anaptecs.jeaf.validation.api.ValidationExecutor if might still be possible to disable / enable request validation without changing the code.

generateRESTResponseValidation

false

Switch defines if request validation for REST Resources / Controllers or REST Clients (aka REST Service Proxies) should be generated. If it is enabled then the generated code will have a dependency on one of the following artifacts:

Spring Boot:

JEAF:

Depending on the implementation of class com.anaptecs.jeaf.validation.api.ValidationExecutor if might still be possible to disable / enable response validation without changing the code.

suppressTechnicalHeaders

false

Switch can be used to suppress technical http headers in generated Java code.

filterCustomHeaders

true

Switch defines whether custom headers of a REST resource should be filtered or not. Default is true. If custom header filtering is defined then a com.anaptecs.jeaf.rest.resource.api.CustomHeaderFilter has to be provided via configuration.t's strongly recommended to not use custom headers at all. However, if needed then at least they should be filtered.

restPathPrefix

optional

Parameter defines the prefix that should be used for REST paths of generated REST resources / controllers. The value provided here will be used as prefix. To be a valid path it has to start with '/' and must not end with '/'.

generateRESTServiceProxies

false

Switch defines whether REST service proxies should be generated or not.

generateRESTServiceProxyConfigFile

false

Switch defines whether a default config file for REST service proxies should be generated or not.

restDefaultSuccessStatusCode

200

Parameter can be used to define the default http status code that should be used when REST requests are successful. By default 200 ("OK") is used. This value will only be used if there is no explicit status code defined on the «RESTOperation».

restDefaultVoidStatusCode

204

Parameter can be used to define the default http status code that should be used when REST requests are successful for operations with return type void. By default 204 (NO_CONTENT) is used. This value will only be used if there is no explicit status code defined on the «RESTOperation».

generateExceptionClasses

false

Switch defines whether exception classes should be generated or not.

generateJUnitTests

false

Switch defines whether a JUnit test case for every service should be generated or not.

 

Configuration Parameters for OpenAPI

Configuration Parameter

Required / Optional / Default

Description

Configuration Parameter

Required / Optional / Default

Description

generateOpenAPISpec

false

Switch defines whether an OpenAPI specification should be generated or not.

validateOpenAPISpec

false

Switch defines if a generated OpenAPI specification should be validated.

enableYAML11Compatibility

false

Switch defines whether YAML 1.1 compatibility mode for OpenAPI should be enabled. In YAML 1.1 there is a big difference compared to YAML 1.2 when it comes to boolean values. In YAML 1.1 besides true and false also yes, no, y, n, on and off are treated as boolean values. This might lead to ugly situations when tools or applications are still working with YAML 1.1 based parsers. To prevent such trouble it is possible to tell JEAF generator that in such cases these values should be quoted.

For further details also see:
Why does Swagger Codegen convert an ON/OFF string enum to TRUE/FALSE?

openAPICommentStyle

|

Configuration parameter allows to define the YAML multi line comment style that is used within the generated OpenAPI specification. For further information about the various options please refer to: https://yaml-multiline.info/


By default | is used which means that new lines will be kept and that there will be a single new line at the end of each comment.

addIgnoredHeadersToOpenAPISpec

false

OpenAPI standard defines that for whatever reason some header fields should not be mentioned in the OpenAPI specification e.g. Authorization header. However from an overall perspective it still might make sense to explicitly show the for better documentation purposes. This can be done by setting this property to true.

For further details also see:
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterObject

openAPIGenericSoftLinkType

 

When working with soft links in your UML model then you can define there that a custom generic type should be used for the soft link. The concrete OpenAPI type that should be used can be defined through this parameter.

In case that the parameter is not defined then it is assumed that the softlink is a string type in OpenAPI.

In case that the type is defined within the same OpenAPI spec then local naming should be used. If type is defined within another OpenAPI spec the standard naming for external types should be used.

suppressClassNameCommentInOpenAPISpec

 

Parameter can be used to suppress link to model element in generated OpenAPI specification. By default fully qualified name of the type is added as comment above the type definition.

 

Configuration Parameters for Components and their Implementations

Configuration Parameter

Required / Optional / Default

Description

Configuration Parameter

Required / Optional / Default

Description

generatePersistentObjects

false

Switch defines whether persistent objects should be generated or not.

peristentObjectsOIDRowName

optional

Default: OID

Name of the row within which the object ID (primary key) will be stored. If the property is not set OID will be used as default.

peristentObjectsVersionLabelRowName

optional

Default: VERSION

Name of the row within which the version label of the object will be stored. The version label is used to determine optimistic lock conflicts.

generatePOJOs

false

Switch defines whether POJOs should be generated or not.

generateDomainObjects

false

Switch defines whether domain objects should be generated or not.

generateComponentImpls

false

Switch defines whether component implementation classes should be generated or not e.g. service and port implementations and their bases classes.

generateComponentRuntimeClasses

false

Switch defines whether component runtime classes should be generated or not e.g. components, component configurations, component factories and service factories.

generateObjectMappers

false

Switch defines whether object mappers should be generated or not.

generateServiceProviderInterfaces

false

Switch defines whether service provider interfaces should be generated or not.

generateServiceProviderImpls

false

Switch defines whether service provider implementations should be generated or not.

generateActivityInterfaces

false

Switch defines whether activity interfaces should be generated or not.

generateActivityImpls

false

Switch defines whether activity implementations should be generated or not.

 

Configuration for Model Reports

Configuration Parameter

Required / Optional / Default

Description

Configuration Parameter

Required / Optional / Default

Description

generateTypesReport

false

Switch enables the generation of a model types report about the model parts which are configured to be processed. The types report is based an model elements that are tagged with the configured stereotypes (see configuration parameter typesReportStereotypes).

typesReportStereotypes

required in case that a types report should be generated

Name of the stereotypes that should be considered when creating types report. Multiple stereotypes have to be separated using ';'.

typesReportName

Model Types

Title of the types report.

typesReportFileName

Model_Types

Name of the file that contains the types report. The file extension will be chosen based on the report format.

typesReportShowAlias

false

Switch defines if within the types report also a row for alias names should be added.

typesReportAliasRowName

Alias

Switch defines the name of the alias row.

typesReportShowPackage

false

Switch defines if for types report also the package of every type should be shown.

typesReportShowProperties

false

Switch defines if for types report also properties of every type should be added.

typesReportGroupByPackage

false

Switch defines if for types report content should be grouped by package.

generateBreakingChangesReport

false

Switch enables the generation of a breaking changes report about the model parts which are configured to be processed. Breaking changes report is based an model elements that are tagged with stereotype «BreakingChange».

breakingChangesReportName

Planned Breaking Changes

Title of the breaking changes report.

breakingChangesReportFileName

Breaking_Changes

Name of the file that contains the breaking changes report. The file extension will be chosen based on the report format.

generateRESTDeprecationReport

false

Switch enables the generation of a REST / OpenAPI deprecation report about the model parts which are configured to be processed.

restDeprecationReportName

REST Deprecation Report

Title of the REST deprecation report.

restDeprecationReportFileName

REST_Deprecation_Report

Name of the file that contains the REST deprecation report. The file extension will be chosen based on the report format.

generateJavaDeprecationReport

false

Switch enables the generation of a Java deprecation report about the model parts which are configured to be processed.

javaDeprecationReportName

Java Deprecation Report

Title of the Java deprecation report.

javaDeprecationReportFileName

Java_Deprecation_Report

Name of the file that contains the Java deprecation report. The file extension will be chosen based on the report format.

deprecationReportFormat

MARKDOWN

Parameter defines the format of the deprecation report. Currently only MARKDOWN is supported.

generateSecurityRolesReport

false

Switch enables the generation of a security roles report about the model parts which are configured to be processed.

securityRolesReportName

Security Roles Report

Title of the security roles report.

securityRolesReportFileName

Security_Roles_Report

Name of the file that contains the security roles report. The file extension will be chosen based on the report format.

securityRolesReportFormat

MARKDOWN

Parameter defines the format of the security roles report. Currently only MARKDOWN is supported.

 

Further Configuration Parameters

Configuration Parameter

Required / Optional / Default

Description

Configuration Parameter

Required / Optional / Default

Description

generateGlobalParts

false

Switch defines whether global parts should be generated or not.

???

generateCustomConstraints

false

Switch defines whether custom constraints should be generated.

generateMessageConstants

false

Switch defines whether a message constants should be generated from resource files or not. Resource files are expected to be located in slot res.

 

Execute JEAF Generator

As you can see in the example below JEAF Generator will be executed in Maven standard phase generate-sources as part of your build. This means that it will be execute as part of your standard build process e.g. mvn clean install.

 

If you just want to run code generation only you can execute goal generate-sources which is supported by most development environments by default via the context menu.

Sample Configuration

The following example shows how to integrate JEAF Generator Maven Plugin into your projects.

 

 

 

Remarks to the example above:

  • We recommend to also build an artifact for the XMI files of your UML model and reference it in your project using Maven dependencies.

  • Further example can be found in the JEAF Generator Samples project in our Git repository: anaptecs/jeaf-generator-samples