You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just stumbled over our documentation for `cds build` and found some
parts difficult to read because of some large walls of prose for
configuration options, e.g. here:
https://cap.cloud.sap/docs/guides/deployment/custom-builds#build-task-properties
Let's make these MD tables, which I think is much more pleasant to read.
---------
Co-authored-by: Daniel O'Grady <103028279+daogrady@users.noreply.github.com>
Copy file name to clipboardExpand all lines: guides/deployment/custom-builds.md
+36-39Lines changed: 36 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,18 +15,19 @@ status: released
15
15
16
16
## Build Configurations {#build-config}
17
17
18
-
`cds build`executes_build tasks_ on your project folders to prepare them for deployment. Build tasks compile source files (typically CDS sources) and create the required artifacts, for example, EDMX files, SAP HANA design-time artifacts, and so on. By default, `cds build` dynamically determines the build tasks from the CDS configuration and from the project context. See [build task properties](#build-task-properties) for a concrete list of the different build task types.
18
+
`cds build`runs_build tasks_ on your project folders to prepare them for deployment. Build tasks compile _source files_ (typically CDS sources) and create required artifacts, for example, EDMX files or SAP HANA design-time artifacts.
19
19
20
-
The CDS model folders and files used by `cds build`are determined as follows:
20
+
Build tasks are derived from the CDS configuration and project context. By default, CDS models are resolved from these sources:
21
21
22
-
- Known root folders, by [default](../../get-started/#project-structure) the folders _db/, srv/, app/_, can also be configured by [`folders.db`, `folders.srv`, `folders.app`](../../get-started/#project-structure).
23
-
- The _src_ folder configured for the individual build task.
24
-
- If [feature toggles](../extensibility/feature-toggles#enable-feature-toggles) are enabled: subfolders of the folder _fts_.
25
-
- CDS Model folders and files defined by the [required services](../../node.js/cds-env#services) of your project. This also includes models used by required built-in CDS services, like [persistent queue](../../node.js/queue#persistent-queue) or [MTX related services](../multitenancy/mtxs#mtx-services-reference).
-_fts/_ and its subfolders when using [feature toggles](../extensibility/feature-toggles#enable-feature-toggles)
24
+
- CDS model folders and files defined by [required services](../../node.js/cds-env#services), including built-in ones
25
+
- Examples: [persistent queue](../../node.js/queue#persistent-queue) or [MTX-related services](../multitenancy/mtxs#mtx-services-reference)
26
+
- Explicit `src` folder configured in the build task
26
27
27
-
Feature toggle folders and required built-in service models will also be added if userdefined models have already been configured as [_model_ option](#build-task-properties) in your build tasks.
28
+
Feature toggle folders and required built-in service models will also be added if user-defined models have been configured as a [`model` option](#build-task-properties) in your build tasks.
28
29
29
-
[Learn more about the calculation of the concrete list of CDS models.](../../node.js/cds-compile#cds-resolve){.learn-more}
30
+
[Learn more about `cds.resolve`](../../node.js/cds-compile#cds-resolve){.learn-more}
30
31
31
32
::: tip If custom build tasks are configured, those properties have precedence
32
33
For example, you want to configure the _src_ folder and add the default models. To achieve this, do not define the _model_ option in your build task:
@@ -49,7 +50,7 @@ For example, you want to configure the _src_ folder and add the default models.
49
50
```
50
51
51
52
52
-
That way, the model paths will still be dynamically determined, but the _src_ folder is taken from the build task configuration. So you benefit from the automatic determination of models, for example, when adding a new external services, or when CAP is changing any built-in service configuration values.
53
+
This way, the model paths will still be dynamically determined, but the _src_ folder is taken from the build task configuration. You still benefit from the automatic determination of models – for example when adding a new external services or when CAP is changing any built-in service defaults.
53
54
:::
54
55
55
56
To control which tasks `cds build` executes, you can add them as part of your [project configuration](../../node.js/cds-env#project-settings) in _package.json_ or _.cdsrc.json_, as outlined [in the following chapter](#build-task-properties).
@@ -76,40 +77,40 @@ The following build tasks represent the default configuration dynamically determ
76
77
77
78
:::
78
79
79
-
::: tip
80
-
The executed build tasks are logged to the command line. You can use them as a blue print – copy & paste them into your CDS configuration and adapt them to your needs. See also the command line help for further details using `cds build --help`.
80
+
::: tip The executed build tasks are logged to the command line
81
+
You can use them as a blue print – copy & paste them into your CDS configuration and adapt them to your needs.
81
82
:::
82
83
83
-
The `for` property defines the executed build task type. Currently supported types are:
84
84
85
-
-`hana`: Creates a deployment layout for the SAP HANA Development Infrastructure (HDI) if an [SAP HANA database](../databases-hana#configure-hana) has been configured.
86
-
-`nodejs` (deprecated: `node-cf`): Creates a deployment layout using a self-contained folder _./gen_ for Node.js apps.
87
-
-`java` (deprecated: `java-cf`): Creates a deployment layout for Java apps.
88
-
-`mtx`: Creates a deployment layout for Node.js applications using multitenancy, feature toggles, extensibility or a combination of these _without_ sidecar architecture.<br>
89
-
In this scenario the required services are implemented by the Node.js application itself which is the default for Node.js.
90
-
-`mtx-sidecar`: Creates a deployment layout for Java or Node.js projects using multitenancy, feature toggles, extensibility or a combination of these _with_ sidecar architecture.<br>
91
-
Java projects have to use a sidecar architecture. For Node.js this is optional, but allows for better scalability in multitenant scenarios.
85
+
The `for` property defines the executed build task type creating its part of the deployment layout. Currently supported types are:
92
86
93
-
[Learn more about **Multitenant Saas Application Deployment**](./to-cf){.learn-more}
94
-
-`mtx-extension`: Creates a deployment layout (_extension.tgz_ file) for an MTX extension project, which is required for extension activation using `cds push`. Extension point restrictions defined by the SaaS app provider are validated by default. If any restriction is violated the build aborts and the errors are logged.<br>
95
-
The build task is created by default for projects that have `"cds": { "extends": "\<SaaS app name\>" }` configured in their _package.json_.
87
+
<stylelang="scss"scoped>
88
+
th { min-width: 160px; }
89
+
</style>
96
90
97
-
[Learn more about **Extending and Customizing SaaS Solutions**](../extensibility/customization){.learn-more}
98
-
- Additional types may be supported by build plugin contributions.
|`hana`| SAP HANA Development Infrastructure (HDI) artifacts<br><br>[Learn more about **configuring SAP HANA**](../databases-hana#configure-hana){.learn-more} |
94
+
|`nodejs`| Node.js applications |
95
+
|`java`| Java applications |
96
+
|`mtx-sidecar`|[MTX](../multitenancy/mtxs)-enabled projects _with_ sidecar architecture.<br><br>[Learn more about **Multitenant Saas Application Deployment**](./to-cf){.learn-more} |
97
+
|`mtx`| MTX-enabled projects _without_ sidecar architecture (Node.js only). Required services are served by the Node.js application itself. |
98
+
|`mtx-extension`| MTX extension project (_extension.tgz_), which is required for extension activation using `cds push`. Extension point restrictions defined by the SaaS app provider are validated by default. If any restriction is violated the build aborts and the errors are logged.<br><br>The build task is created by default for projects that have `"cds": { "extends": "\<SaaS app name\>" }` configured in their _package.json_.<br><br>[Learn more about **Extending and Customizing SaaS Solutions**](../extensibility/customization){.learn-more} |
99
99
100
-
[Learn more about **Running Build Plugins**](#run-the-plugin){.learn-more}
100
+
Additional types may be supported by build plugin contributions.
101
101
102
-
Build tasks can be customized using the following properties:
102
+
#### Customization
103
103
104
-
-`src`: Source folder of the module that is about to be build.
105
-
-`dest`: Optional destination of the modules builds, relative to the enclosing project. The _src_ folder is used by default.
106
-
-`options`: Sets the options according to the target technology.<br>
107
-
-`model`: It has type _string_ or _array of string_. The given list of folders or individual _.cds_ file names is resolved based on the current working dir or the project folder passed to cds build. CDS built-in models (prefix _@sap/cds*_) are added by default to the user-defined list of models.
104
+
Build tasks can be customized using the following properties:
108
105
109
-
[Learn more about **Core Data Services (CDS)**](../../cds/){.learn-more}
|`dest`| Optional destination of the module's build destination, relative to the enclosing project. The _src_ folder is used by default. |
110
+
|`options`|`model`: _string_ or _array of string_<br><br>The given list of folders or individual _.cds_ file names is resolved based on the current working directory or project folder passed to `cds build`.<br><br>CDS built-in models (prefix _@sap/cds*_) are added by default to the user-defined list of models. |
110
111
111
112
**Note:**
112
-
Alternatively you can execute build tasks and pass the described arguments from command line. See also `cds build --help` for further details.
113
+
Alternatively you can execute build tasks and pass the described arguments to the command line. See also `cds build --help` for further details.
113
114
114
115
### Build Target Folder {#build-target-folder}
115
116
@@ -178,14 +179,12 @@ Packaging of the tarball content is based on the rules of the [`npm pack`](https
178
179
Java projects use the project's root folder _./_ as build target folder by default.<br>
179
180
This causes `cds build` to create the build output below the individual source folders. For example, _db/src/gen_ contains the build output for the _db/_ folder. No source files are copied to _db/src/gen_ because they're assumed to be deployed from their original location, the _db/_ folder itself.
180
181
181
-
## Implement a Build Plugin {#custom-build-plugins}
182
+
## Implement a Build Plugin <Sinceversion="7.5.0"of="@sap/cds-dk" /> {#custom-build-plugins}
182
183
183
184
CDS already offers build plugins to create deployment layouts for the most use cases. However, you will find cases where these plugins are not enough and you have to develop your own. This section shows how such a build plugin can be implemented and how it can be used in projects.
184
185
185
186
Build plugins are run by `cds build` to generate the required deployment artifacts. Build tasks hold the actual project specific configuration. The task's `for` property value has to match the build plugin ID.
186
187
187
-
**Note:** Minimum version 7.5.0 of `@sap/cds-dk` and `@sap/cds` needs to be installed.
188
-
189
188
The following description uses the [postgres build plugin](https://github.com/cap-js/cds-dbs/blob/55e511471743c0445d41e8297f5530abe167a270/postgres/cds-plugin.js#L9-L48) as reference implementation. It combines runtime and design-time integration in a single plugin `@cap-js/postgres`.
190
189
191
190
### Add Build Logic
@@ -244,9 +243,7 @@ The compiled CSN model can be accessed using the asynchronous methods `model()`
244
243
- To get a CSN model without features, use the method `baseModel()` instead. The model can be used as input for further [model processing](../../node.js/cds-compile#cds-compile-to-xyz), like `to.edmx`, `to.hdbtable`, `for.odata`, etc.
245
244
- Use [`cds.reflect`](../../node.js/cds-reflect) to access advanced query and filter functionality on the CDS model.
246
245
247
-
#### Add build task type to cds schema
248
-
249
-
**Note:** Minimum version `7.6.0` of `@sap/cds-dk` and `@sap/cds` needs to be installed.
246
+
#### Add build task type to cds schema <Since version="7.6.0" of="@sap/cds-dk" />
250
247
251
248
In addition you can also add a new build task type provided by your plugin. This build task type will then be part of code completion suggestions for `package.json` and `.cdsrc.json` files.
252
249
@@ -261,7 +258,7 @@ The `cds.build.Plugin` class provides methods for copying or writing contents to
0 commit comments