Skip to content

    Customizing cds build

    Choosing Target Folder

    • For Node.js projects, the ./gen folder below the project root is used by default. All source files are copied to it by cds build, which makes it a self-contained folder that is ready for deployment.
    • For Java projects, the project’s root folder ./ is used by default, which means that the build output is stored below the individual source folders. For example, db/src/gen would contain the build output of the default db folder. No source files are copied to db/src/gen because they’re assumed to be deployed from the db folder itself.

    If you want to change the default target folder, use the target property in your package.json.

    "cds": { "build": { "target" : "custom/folder"}}

    It’s resolved based on the application’s root folder.

    Custom Build Configurations

    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, etc. All known root folders (app, db, and srv) or those configured in the build tasks are built.

    By default, cds build derives build tasks from the project contents:

    • A hana build task is created if an SAP HANA service binding is defined.
    • A node-cf build task for projects using the Nodejs runtime.
    • A java-cf build task for projects using the CAP Java SDK.
    • A mtx build task for multitenancy projects using the Node.js runtime. For Java projects, a mtx build task has to be configured manually as it is not created by default.

    To control which tasks cds build executes, you can add them as part of your project configuration in package.json or .cdsrc.json.

    The following build tasks are a default configuration used for Node.js projects:

      "build": {
        "target": "gen",
        "tasks": [
          {"for":"hana",    "src":"db",  "options": {"model": ["db","srv"] }},
          {"for":"node-cf", "src":"srv", "options": {"model": ["db","srv"] }}

    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.

    Build Task Properties

    • for: Target technology for which the build is executed. Currently supported types are:
      • node-cf: Creates a deployment layout for Node.js apps on Cloud Foundry.
      • java-cf: Creates a deployment layout for Java apps on Cloud Foundry.
      • hana: Creates a deployment layout for SAP HANA HDI.
      • mtx: Creates a deployment layout for multitenant applications.
      • fiori: Creates a deployment layout for SAP Fiori.
    • src: Source folder of the module that is about to be build.
    • dest: Optional destination of the modules builds, relative to the enclosing project. The src folder is used by default.
    • options: Sets technology-specific options according to the target technology. The target technologies node-cf, java-cf, and hana support the option model, which can be either of type string or string array. The cds build uses the given folders or .cds files as input for resolving the entire CDS model.