cds:generate
Full name:
com.sap.cds:cds-maven-plugin:2.8.1: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.
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:
FULL .Default: FULL User Property: cds.generate.annotationDetailLevel |
<basePackage> |
String |
- |
Base package of generated Java classes. User Property: cds.generate.basePackage |
<cqnService> |
Boolean |
- |
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 |
- |
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. Default: localized.** User Property: cds.generate.excludes |
<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 |
<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 .User Property: cds.generate.methodStyle |
<sharedInterfaces> |
boolean |
2.8.0 |
Enables the usage of interfaces generated for the global types with inline anonymous arrayed types in the interfaces generated for actions and functions. With this switch off, the interfaces for an actions or functions always represent these types as inner interfaces which might lead to a duplication of code. With this switch on, the globally generated interfaces will be preferred over the inline interfaces. This might be incompatible with existing code that uses the inline interfaces. Default: false User Property: cds.generate.sharedInterfaces |
<skip> |
boolean |
- |
Skip execution of this goal. Default: false User Property: cds.generate.skip |
<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 added
MINIMAL
annotation is added with the name of the plugin.
FULL
annotation is added with full details
FULL
.- Type:
com.sap.cds.generator.GeneratedAnnotationDetailLevel
- Since:
2.1.0
- Required:
No
- User Property:
cds.generate.annotationDetailLevel
- Default:
FULL
<basePackage>
Base package of generated Java classes.
- Type:
java.lang.String
- Required:
No
- User Property:
cds.generate.basePackage
<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>
Determine whether to create interfaces for CqnServices.
- Type:
java.lang.Boolean
- 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>
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
- Default:
localized.**
<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
<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
<sharedInterfaces>
Enables the usage of interfaces generated for the global types with inline anonymous arrayed types in the interfaces generated for actions and functions. With this switch off, the interfaces for an actions or functions always represent these types as inner interfaces which might lead to a duplication of code. With this switch on, the globally generated interfaces will be preferred over the inline interfaces. This might be incompatible with existing code that uses the inline interfaces.
- Type:
boolean
- Since:
2.8.0
- Required:
No
- User Property:
cds.generate.sharedInterfaces
- Default:
false
<skip>
Skip execution of this goal.
- Type:
boolean
- Required:
No
- User Property:
cds.generate.skip
- 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