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 |
---|---|---|
| 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. |
| Artifact ID of the artifact that contains the XMI files of the UML model. | |
| XMI Path inside the artifact that contains the XMI files of the UML model. | |
| 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 |
| 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.
|
| 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. | |
| required in case of code generation from UML models but not for message constants only. | Directory where all files that belong to the |
| required | Directory where all files that belong to the |
| required | Directory where all files that belong to the |
| required | Directory where all files that belong to the |
| optional | Parameter defines if By default it is disabled. |
| optional | Parameter defines if By default it is disabled. |
|
| Besides MagicDrawUML JEAF Generator also supports Eclipse Papyrus as modeling tool ( |
|
| 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 ( |
|
| Name of the root template for customer specific extensions |
| optional | List of custom check files that will be used to run customer specific checks of the UML model. |
| 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. |
| optional | List of resource files that should be ignored when generating message constants classes from resource files. |
| optional | Company information for header of generated files. |
| optional | Author information for header of generated files. |
| optional | Copyright information for header of generated files. |
| optional | Version information for header of generated files. |
|
| Parameter can be used to disable formatting of generated sources and resources in general. |
|
| Parameter can be used to disable formatting of generated sources only. |
|
| Parameter can be used to disable formatting of generated resources only. |
| 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. |
| 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. |
|
| Parameter defines the grouping and sorting of Java import statements. |
|
| Parameter defines the grouping and sorting of static Java import statements. |
|
| Switch defines if |
|
| Switch defines if |
|
| Switch defines if |
|
| Switch defines if |
|
| Switch defines whether POJO's should be serializable or not. |
|
| 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 |
|
| Switch defines whether generated |
|
| Switch defines if Java Validation Annotation |
|
| Switch defines whether Java Validation Annotations should not only be generated for explicitly modeled annotations but also from multiplicity of modeled attributes. |
|
| Switch defines whether Java Validation Annotations should not only be generated for explicitly modeled annotations but also from multiplicity of modeled associations. |
|
| 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 |
|
| Switch defines if an Which properties will be used for the |
|
| Switch defines if an |
|
| Switch defines whether for the Java representation of OpenAPI Data Types as |
|
| Switch enables that JEAF Generator generates a |
|
| 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. |
|
| Switch defines whether the generated set methods for one-to-many associations should be public or not. |
|
| Switch defines whether the generated set methods for to-one associations has checks for null values of parameters. |
|
| 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 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 |
|
| 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 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 |
|
| 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 |
|
| 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. |
|
| 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 |
|
| 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. |
|
| Parameter defines if JAX-RS annotations for service objects or POJOs should be generated. If the parameter is set to |
|
| Parameter defines if Jackson annotations for service objects or POJOs should be generated. If the parameter is set to |
|
| Parameter can be used to define a list of warning that should be suppressed in the generated code. This will lead to annotation |
|
| Parameter can be used to suppress all warnings in generated code It's strongly recommended to not use this feature ;-) |
|
| Switch defines if errors during code generation should break the build. This feature is mainly intended for test purposes of JEAF Generator itself. |
|
| Parameter can be used to add |
|
| Parameter can be used to also add timestamp of code generation to the |
|
| Parameter can be used to also add the defined comment of code generation to the |
|
| 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 : |
|
| 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: |
Configuration Parameters for Services / REST Resources
Configuration Parameter | Required / Optional / Default | Description |
---|---|---|
|
| Switch defines whether service objects should be generated or not. |
|
| Switch defines whether service interfaces should be generated or not. |
|
| Switch defines whether service proxies should be generated or not. |
|
| Switch defines whether REST resources should be generated or not. |
|
| Switch defines if target runtime specific security annotations (e.g. |
|
| Switch defines if in case of Spring deprecated |
|
| 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 |
| 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 |
|
| Switch can be used to suppress technical http headers in generated Java code. |
|
| Switch defines whether custom headers of a REST resource should be filtered or not. Default is |
| 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 |
|
| Switch defines whether REST service proxies should be generated or not. |
|
| Switch defines whether a default config file for REST service proxies should be generated or not. |
|
| 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 |
|
| 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 |
|
| Switch defines whether exception classes should be generated or not. |
|
| 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 |
---|---|---|
|
| Switch defines whether an OpenAPI specification should be generated or not. |
|
| Switch defines if a generated OpenAPI specification should be validated. |
|
| 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 For further details also see: |
|
| 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/
|
|
| OpenAPI standard defines that for whatever reason some header fields should not be mentioned in the OpenAPI specification e.g. For further details also see: |
|
| 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. |
|
| 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 |
---|---|---|
|
| Switch defines whether persistent objects should be generated or not. |
| optional Default: | Name of the row within which the object ID (primary key) will be stored. If the property is not set |
| optional Default: | 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. |
|
| Switch defines whether POJOs should be generated or not. |
|
| Switch defines whether domain objects should be generated or not. |
|
| Switch defines whether component implementation classes should be generated or not e.g. service and port implementations and their bases classes. |
|
| Switch defines whether component runtime classes should be generated or not e.g. components, component configurations, component factories and service factories. |
|
| Switch defines whether object mappers should be generated or not. |
|
| Switch defines whether service provider interfaces should be generated or not. |
|
| Switch defines whether service provider implementations should be generated or not. |
|
| Switch defines whether activity interfaces should be generated or not. |
|
| Switch defines whether activity implementations should be generated or not. |
Configuration for Model Reports
Configuration Parameter | Required / Optional / Default | Description |
---|---|---|
|
| 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 |
| 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 |
|
| Title of the types report. |
|
| Name of the file that contains the types report. The file extension will be chosen based on the report format. |
|
| Switch defines if within the types report also a row for alias names should be added. |
|
| Switch defines the name of the alias row. |
|
| Switch defines if for types report also the package of every type should be shown. |
|
| Switch defines if for types report also properties of every type should be added. |
|
| Switch defines if for types report content should be grouped by package. |
|
| 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 |
|
| Title of the breaking changes report. |
|
| Name of the file that contains the breaking changes report. The file extension will be chosen based on the report format. |
|
| Switch enables the generation of a REST / OpenAPI deprecation report about the model parts which are configured to be processed. |
|
| Title of the REST deprecation report. |
|
| Name of the file that contains the REST deprecation report. The file extension will be chosen based on the report format. |
|
| Switch enables the generation of a Java deprecation report about the model parts which are configured to be processed. |
|
| Title of the Java deprecation report. |
|
| Name of the file that contains the Java deprecation report. The file extension will be chosen based on the report format. |
|
| Parameter defines the format of the deprecation report. Currently only |
|
| Switch enables the generation of a security roles report about the model parts which are configured to be processed. |
|
| Title of the security roles report. |
|
| Name of the file that contains the security roles report. The file extension will be chosen based on the report format. |
|
| Parameter defines the format of the security roles report. Currently only |
Further Configuration Parameters
Configuration Parameter | Required / Optional / Default | Description |
---|---|---|
|
| Switch defines whether global parts should be generated or not. ??? |
|
| Switch defines whether custom constraints should be generated. |
|
| Switch defines whether a message constants should be generated from resource files or not. Resource files are expected to be located in slot |
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