1

This question is similar to Support composer_manager AND drupal-composer/drupal-project with contrib module, but I am asking it with a different angle this time. Imo this justifies a separate question, as an answer to this could be generally useful beyond my specific use case.

Technical background

packages.drupal.org re-publishes module packages from drupal.org with auto-generated composer.json.

The main "module package" becomes a composer package with "type": "drupal-module". Each "submodule" (module in a subdirectory) becomes a package with "type": "metapackage".

The composer.json for each submodule is generated from the *.info file. E.g. if the *.info file says dependencies[] = composer_manager, then the composer.json for this metapackage will require drupal/composer_manager. It seems that composer.json in the submodule is ignored.

For the main / root package, perhaps an existing composer.json is not ignored. Not sure about that.

Sometimes the generated composer.json is not exactly what I want.

The functionality on packages.drupal.org is provided by https://www.drupal.org/project/project_composer. There are database tables that contain information about modules uploaded to drupal.org (via https://www.drupal.org/project/project), and project_composer derives Composer data from this.

Question

Is it possible for a contrib module to alter the composer.json that will be generated for the main module package and for a submodule metapackage?

E.g.:

  • Prevent a module dependency from the *.info file to be added as a Composer requirement.
  • Add an additional 3rd party Composer requirement.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.