cds:generate
Full name:
com.sap.cds:cds-maven-plugin:4.0.0:generate
Description:
Generates Java POJOs for type-safe access to the CDS model.
This goal scans the resource directory for a csn.json file and uses it for Java source code generation. It also adds the code output directory to the project's source code directories configuration. This allows you to use the generated Java classes in your custom code without any additional configuration in the project.
Note: If you call this goal from the command line (mvn cds:generate
) and you want to leverage the configuration (e.g. basePackage
) from the pom.xml, you have to specify the execution id (mvn cds:generate@<execution.id>
) of this goal from the pom.xml
:
...
<execution>
<id>cds.generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<basePackage>cds.gen</basePackage>
</configuration>
</execution>
...
For this example, the required command line is mvn cds:generate@cds.generate
.
If you call this goal without the execution id, you have to provide the configuration with properties on the command line (
mvn cds:generate -Dcds.generate.basePackage=cds.gen
).
Attributes:
- Requires a Maven project to be executed.
- Executes as an aggregator goal.
- The goal is not marked as thread-safe and thus does not support parallel builds.
- Since version:
1.7.0
. - Binds by default to the lifecycle phase:
generate-resources
.
Required Parameters
Name | Type | Since | Description |
---|---|---|---|
<codeOutputDirectory> |
File |
- |
The output directory for generated Java classes. This directory is added to the source directories of your project. Default: ${project.basedir}/src/gen/ User Property: cds.codeOutputDirectory |
Optional Parameters
Name | Type | Since | Description |
---|---|---|---|
<annotationDetailLevel> |
GeneratedAnnotationDetailLevel |
2.1.0 |
Defines the level of the details of the annotation @javax.annotation.processing.Generated that is added to the accessor interfaces. Following levels of the details are available:
Default: MINIMAL User Property: cds.generate.annotationDetailLevel |
<basePackage> |
String |
- |
Base package of generated Java classes. User Property: cds.generate.basePackage |
<betterNames> |
boolean |
4.0.0 |
Enables technical conversions to better support CDS models with names clashing with Java keywords or characters that are not allowed in Java identifiers. Default: false User Property: cds.generate.betterNames |
<cqnService> |
Boolean |
2.0.4 |
Deprecated. No reason given Determine whether to create interfaces for CqnServices. Default: true User Property: cds.generate.cqnService |
<csnFile> |
File |
1.8.0 |
Location of the csn file used for Java source code generation. If not specified, all resource directories are scanned for a csn.json file. If multiple csn.json files are found, the first one is used.User Property: cds.generate.csnFile |
<documentation> |
boolean |
1.17.0 |
Determine whether to generate Javadoc for the generated interfaces. Default: true User Property: cds.documentation |
<eventContext> |
boolean |
- |
Deprecated. No reason given Determine whether to generate interfaces extending EventContext for actions and functions. Default: true User Property: cds.generate.eventContext |
<excludes> |
List<String> |
- |
Namespaces/definitions of CDS model to be excluded from source code generation. From the set of all included definitions, the following namespaces/definitions will be excluded. An exclude always overrules an include.
For example, the exclude my.bookshop.* will exclude all definitions with namespace my.bookshop and the exclude my.bookshop.** will exclude all definitions with fully qualified name beginning with my.bookshop. User Property: cds.generate.excludes |
<feature> |
String |
3.2.0 |
Specifies the generation feature to execute. If a feature is specified, this goal may only be called from the command line.
Supported features are:
Note: This parameter must not be used in a pom.xml , it is intended for other tools to provide additional features for code generation.User Property: cds.generate.feature |
<generatedHandlersPackage> |
String |
3.2.0 |
Defines the package within the application service package where the generated handlers will be created.
Note: This parameter must not be used in a pom.xml , it is intended for other tools to provide additional features for code generation.
Default: handlers User Property: cds.generate.handlers.package |
<includes> |
List<String> |
1.21.0 |
Namespaces/definitions of CDS model to be included into source code generation. By default, all definitions/namespaces are included unless an includes is specified explicitly. In which case, only the explicitly specified definitions/namespaces are included.
For example, the include my.bookshop.orders.* will include only those definitions with namespace my.bookshop.orders and the include my.bookshop.books.** will include all definitions with fully qualified name beginning with my.bookshop.books. User Property: cds.generate.includes |
<interfacesForAspects> |
boolean |
3.0.0 |
Enables the generation of accessor interfaces for entities representing the targets of compositions of aspects. This might be incompatible with existing code as the type of the getters and setters for compositions will change. Default: false User Property: cds.generate.interfacesForAspects |
<methodStyle> |
MethodStyle |
- |
Defines method styling for accessor interface methods; follows either the Java Bean style method naming for getters & setters denoted by BEAN or the Fluent style denoted by FLUENT .
Valid values: BEAN or FLUENT .Default: BEAN User Property: cds.generate.methodStyle |
<overwrite> |
boolean |
3.2.0 |
Overwrite existing files during code generation. If set to true , existing files will be overwritten.
Note:Use carefully, as it overwrites existing files without confirmation and does not back up existing files. This parameter must not be used in a pom.xml , it is intended for other tools to provide additional features for code generation.
Default: false User Property: cds.generate.overwrite |
<skip> |
boolean |
- |
Skip execution of this goal. Default: false User Property: cds.generate.skip |
<strictSetters> |
boolean |
3.3.0 |
Enables strict setters for generated accessor interfaces. This enforces usage of typed interfaces in setters of associations, instead of using more generic Map<String, Object> or List<Map<String, Object>> argument types.Default: false User Property: cds.generate.strictSetters |
<testSources> |
boolean |
1.31.0 |
Determine whether to add generated sources to compile or test sources. Default: false User Property: cds.generate.testSources |
Parameter Details
<annotationDetailLevel>
Defines the level of the details of the annotation @
javax.annotation.processing.Generated
that is added to the accessor interfaces. Following levels of the details are available:
NONE
annotation is not addedMINIMAL
annotation is added with the name of the plugin.FULL
annotation is added with full details
- Type:
com.sap.cds.generator.GeneratedAnnotationDetailLevel
- Since:
2.1.0
- Required:
No
- User Property:
cds.generate.annotationDetailLevel
- Default:
MINIMAL
<basePackage>
Base package of generated Java classes.
- Type:
java.lang.String
- Required:
No
- User Property:
cds.generate.basePackage
<betterNames>
Enables technical conversions to better support CDS models with names clashing with Java keywords or characters that are not allowed in Java identifiers.
- Type:
boolean
- Since:
4.0.0
- Required:
No
- User Property:
cds.generate.betterNames
- Default:
false
<codeOutputDirectory>
The output directory for generated Java classes. This directory is added to the source directories of your project.
- Type:
java.io.File
- Required:
Yes
- User Property:
cds.codeOutputDirectory
- Default:
${project.basedir}/src/gen/
<cqnService>
Deprecated.
No reason given
No reason given
Determine whether to create interfaces for CqnServices.
- Type:
java.lang.Boolean
- Since:
2.0.4
- Required:
No
- User Property:
cds.generate.cqnService
- Default:
true
<csnFile>
Location of the csn file used for Java source code generation. If not specified, all resource directories are scanned for a
csn.json
file. If multiple csn.json
files are found, the first one is used.- Type:
java.io.File
- Since:
1.8.0
- Required:
No
- User Property:
cds.generate.csnFile
<documentation>
Determine whether to generate Javadoc for the generated interfaces.
- Type:
boolean
- Since:
1.17.0
- Required:
No
- User Property:
cds.documentation
- Default:
true
<eventContext>
Deprecated.
No reason given
No reason given
Determine whether to generate interfaces extending EventContext for actions and functions.
- Type:
boolean
- Required:
No
- User Property:
cds.generate.eventContext
- Default:
true
<excludes>
Namespaces/definitions of CDS model to be excluded from source code generation. From the set of all included definitions, the following namespaces/definitions will be excluded. An exclude always overrules an include.
For example, the exclude my.bookshop.* will exclude all definitions with namespace my.bookshop and the exclude my.bookshop.** will exclude all definitions with fully qualified name beginning with my.bookshop.
For example, the exclude my.bookshop.* will exclude all definitions with namespace my.bookshop and the exclude my.bookshop.** will exclude all definitions with fully qualified name beginning with my.bookshop.
- Type:
java.util.List<java.lang.String>
- Required:
No
- User Property:
cds.generate.excludes
<feature>
Specifies the generation feature to execute. If a feature is specified, this goal may only be called from the command line.
Supported features are:
Note: This parameter must not be used in a
Supported features are:
- EVENT_HANDLERSGenerate event handler classes for actions and functions
Note: This parameter must not be used in a
pom.xml
, it is intended for other tools to provide additional features for code generation.- Type:
java.lang.String
- Since:
3.2.0
- Required:
No
- User Property:
cds.generate.feature
<generatedHandlersPackage>
Defines the package within the application service package where the generated handlers will be created.
Note: This parameter must not be used in a
Note: This parameter must not be used in a
pom.xml
, it is intended for other tools to provide additional features for code generation.
- Type:
java.lang.String
- Since:
3.2.0
- Required:
No
- User Property:
cds.generate.handlers.package
- Default:
handlers
<includes>
Namespaces/definitions of CDS model to be included into source code generation. By default, all definitions/namespaces are included unless an includes is specified explicitly. In which case, only the explicitly specified definitions/namespaces are included.
For example, the include my.bookshop.orders.* will include only those definitions with namespace my.bookshop.orders and the include my.bookshop.books.** will include all definitions with fully qualified name beginning with my.bookshop.books.
For example, the include my.bookshop.orders.* will include only those definitions with namespace my.bookshop.orders and the include my.bookshop.books.** will include all definitions with fully qualified name beginning with my.bookshop.books.
- Type:
java.util.List<java.lang.String>
- Since:
1.21.0
- Required:
No
- User Property:
cds.generate.includes
<interfacesForAspects>
Enables the generation of accessor interfaces for entities representing the targets of compositions of aspects. This might be incompatible with existing code as the type of the getters and setters for compositions will change.
- Type:
boolean
- Since:
3.0.0
- Required:
No
- User Property:
cds.generate.interfacesForAspects
- Default:
false
<methodStyle>
Defines method styling for accessor interface methods; follows either the Java Bean style method naming for getters & setters denoted by
Valid values:
BEAN
or the Fluent style denoted by FLUENT
.
Valid values:
BEAN
or FLUENT
.- Type:
com.sap.cds.generator.MethodStyle
- Required:
No
- User Property:
cds.generate.methodStyle
- Default:
BEAN
<overwrite>
Overwrite existing files during code generation. If set to
Note:Use carefully, as it overwrites existing files without confirmation and does not back up existing files.
This parameter must not be used in a
true
, existing files will be overwritten.
Note:Use carefully, as it overwrites existing files without confirmation and does not back up existing files.
This parameter must not be used in a
pom.xml
, it is intended for other tools to provide additional features for code generation.
- Type:
boolean
- Since:
3.2.0
- Required:
No
- User Property:
cds.generate.overwrite
- Default:
false
<skip>
Skip execution of this goal.
- Type:
boolean
- Required:
No
- User Property:
cds.generate.skip
- Default:
false
<strictSetters>
Enables strict setters for generated accessor interfaces. This enforces usage of typed interfaces in setters of associations, instead of using more generic
Map<String, Object>
or List<Map<String, Object>>
argument types.- Type:
boolean
- Since:
3.3.0
- Required:
No
- User Property:
cds.generate.strictSetters
- Default:
false
<testSources>
Determine whether to add generated sources to compile or test sources.
- Type:
boolean
- Since:
1.31.0
- Required:
No
- User Property:
cds.generate.testSources
- Default:
false