SAP / cloud-mta-build-tool

Multi-Target Application (MTA) build tool for Cloud Applications https://sap.github.io/cloud-mta-build-tool
Apache License 2.0
136 stars 56 forks source link

Apply before-all for mbt sbom-gen #1112

Open Fabian-K opened 4 months ago

Fabian-K commented 4 months ago

A typical CAP project relies on before-all to build the project. As an example, the following mta.yaml is generated by cds init & cds add mta

---
_schema-version: '3.1'
ID: bookshop
version: 1.0.0
description: "A simple CAP project."
parameters:
  enable-parallel-deployments: true
build-parameters:
  before-all:
    - builder: custom
      commands:
        - npx cds build --production
modules:
  - name: bookshop-srv
    type: nodejs
    path: gen/srv
    parameters:
      buildpack: nodejs_buildpack
    build-parameters:
      builder: npm
    provides:
      - name: srv-api # required by consumers of CAP services (e.g. approuter)
        properties:
          srv-url: ${default-url}
    requires: []

Executing mbt sbom-gen for such a project fails with the following error because gen/srv is generated by cds build within before-all.

[2024-03-04 12:27:54]  INFO start to generate some file
[2024-03-04 12:27:54]  INFO start to generate sbom for module ...
[2024-03-04 12:27:54]  INFO executing the "npm install" command...
Error: generate sbom file failed: could not execute the "npm install" command: chdir /workspace/source/gen/srv: no such file or directory
[2024-03-04 12:27:54] ERROR generate sbom file failed: could not execute the "npm install" command: chdir /workspace/source/gen/srv: no such file or directory

Can mbt sbom-gen be updated to apply before-all steps before generating the sbom?

Thanks, Fabian