Skip to content

Commit 6a0c2c0

Browse files
swaldmanndaogrady
andauthored
More tables for cds build (#2011)
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>
1 parent 5570d24 commit 6a0c2c0

1 file changed

Lines changed: 36 additions & 39 deletions

File tree

guides/deployment/custom-builds.md

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ status: released
1515

1616
## Build Configurations {#build-config}
1717

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.
1919

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:
2121

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).
22+
- _db/_, _srv/_, _app/_[default root folders](../../get-started/#project-structure)
23+
- _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
2627

27-
Feature toggle folders and required built-in service models will also be added if user defined 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.
2829

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}
3031

3132
::: tip If custom build tasks are configured, those properties have precedence
3233
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.
4950
```
5051

5152

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 modelsfor example when adding a new external services or when CAP is changing any built-in service defaults.
5354
:::
5455

5556
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
7677

7778
:::
7879

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.
8182
:::
8283

83-
The `for` property defines the executed build task type. Currently supported types are:
8484

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:
9286

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+
<style lang="scss" scoped>
88+
th { min-width: 160px; }
89+
</style>
9690

97-
[Learn more about **Extending and Customizing SaaS Solutions**](../extensibility/customization){.learn-more}
98-
- Additional types may be supported by build plugin contributions.
91+
| Property | Description |
92+
|------------------|-----------------------------------------------------------------------------|
93+
| `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} |
9999

100-
[Learn more about **Running Build Plugins**](#run-the-plugin){.learn-more}
100+
Additional types may be supported by build plugin contributions.
101101

102-
Build tasks can be customized using the following properties:
102+
#### Customization
103103

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:
108105

109-
[Learn more about **Core Data Services (CDS)**](../../cds/){.learn-more}
106+
| Property | Description |
107+
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
108+
| `src` | Source folder of module to be built. |
109+
| `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. |
110111

111112
**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.
113114

114115
### Build Target Folder {#build-target-folder}
115116

@@ -178,14 +179,12 @@ Packaging of the tarball content is based on the rules of the [`npm pack`](https
178179
Java projects use the project's root folder _./_ as build target folder by default.<br>
179180
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.
180181

181-
## Implement a Build Plugin {#custom-build-plugins}
182+
## Implement a Build Plugin <Since version="7.5.0" of="@sap/cds-dk" /> {#custom-build-plugins}
182183

183184
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.
184185

185186
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.
186187

187-
**Note:** Minimum version 7.5.0 of `@sap/cds-dk` and `@sap/cds` needs to be installed.
188-
189188
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`.
190189

191190
### Add Build Logic
@@ -244,9 +243,7 @@ The compiled CSN model can be accessed using the asynchronous methods `model()`
244243
- 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.
245244
- Use [`cds.reflect`](../../node.js/cds-reflect) to access advanced query and filter functionality on the CDS model.
246245
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" />
250247
251248
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.
252249
@@ -261,7 +258,7 @@ The `cds.build.Plugin` class provides methods for copying or writing contents to
261258
```js [postgres/lib/build.js]
262259
await this.copy(path.join(this.task.src, 'package.json')).to('package.json');
263260
await this.write({
264-
dependencies: { '@sap/cds': '^7', '@cap-js/postgres': '^1' },
261+
dependencies: { '@sap/cds': '^9', '@cap-js/postgres': '^2' },
265262
scripts: { start: 'cds-deploy' }
266263
}).to('package.json');
267264
```

0 commit comments

Comments
 (0)