/
Maven Integration

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